Fixed bug https://bugs.launchpad.net/appy/+bug/408826, implemented blueprints https://blueprints.launchpad.net/appy/+spec/show-or-hide-application-portlet, https://blueprints.launchpad.net/appy/+spec/associate-a-workflow-to-custom-tool-or-flavour and https://blueprints.launchpad.net/appy/+spec/csv-parser
This commit is contained in:
parent
4c29c7c484
commit
facbe7fa3d
8 changed files with 229 additions and 16 deletions
|
@ -456,4 +456,7 @@ class Config:
|
|||
# frontPage = True will replace the Plone front page with a page
|
||||
# whose content will come fron i18n label "front_page_text".
|
||||
self.frontPage = False
|
||||
# If you don't need the portlet that appy.gen has generated for your
|
||||
# application, set the following parameter to False.
|
||||
self.showPortlet = True
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -227,6 +227,7 @@ class Generator:
|
|||
# Potentially, sub-modules exist
|
||||
moduleFolder = os.path.dirname(moduleFile)
|
||||
for elem in os.listdir(moduleFolder):
|
||||
if elem.startswith('.'): continue
|
||||
subModuleName, ext = os.path.splitext(elem)
|
||||
if ((ext == '.py') and (subModuleName != '__init__')) or \
|
||||
os.path.isdir(os.path.join(moduleFolder, subModuleName)):
|
||||
|
|
|
@ -354,13 +354,16 @@ class Generator(AbstractGenerator):
|
|||
"['portal_catalog']\n" % blackClass
|
||||
# Compute workflows
|
||||
workflows = ''
|
||||
for classDescr in self.classes:
|
||||
allClasses = self.classes[:]
|
||||
if self.customToolDescr:
|
||||
allClasses.append(self.customToolDescr)
|
||||
if self.customFlavourDescr:
|
||||
allClasses.append(self.customFlavourDescr)
|
||||
for classDescr in allClasses:
|
||||
if hasattr(classDescr.klass, 'workflow'):
|
||||
wfName = WorkflowDescriptor.getWorkflowName(
|
||||
classDescr.klass.workflow)
|
||||
className = ArchetypesClassDescriptor.getClassName(
|
||||
classDescr.klass)
|
||||
workflows += '\n "%s":"%s",' % (className, wfName)
|
||||
workflows += '\n "%s":"%s",' % (classDescr.name, wfName)
|
||||
# Generate the resulting file.
|
||||
repls = self.repls.copy()
|
||||
repls['allClassNames'] = allClassNames
|
||||
|
@ -369,6 +372,7 @@ class Generator(AbstractGenerator):
|
|||
repls['imports'] = '\n'.join(imports)
|
||||
repls['appClasses'] = "[%s]" % ','.join(appClasses)
|
||||
repls['minimalistPlone'] = self.config.minimalistPlone
|
||||
repls['showPortlet'] = self.config.showPortlet
|
||||
repls['appFrontPage'] = self.config.frontPage == True
|
||||
repls['workflows'] = workflows
|
||||
self.copyFile('Install.py', repls, destFolder='Extensions')
|
||||
|
@ -515,6 +519,12 @@ class Generator(AbstractGenerator):
|
|||
# Implicitly, the title will be added by Archetypes. So I need
|
||||
# to define a property for it.
|
||||
wrapperDef += self.generateWrapperProperty('title', String())
|
||||
# For custom tool, flavour and pod template, add a call to a method
|
||||
# that allows to custom element to update the basic element.
|
||||
if isinstance(c, CustomToolClassDescriptor) or \
|
||||
isinstance(c, CustomFlavourClassDescriptor):
|
||||
wrapperDef += " if hasattr(%s, 'update'): %s.update(%s.__bases__[1])" % \
|
||||
(parentClass, parentClass, parentWrapper)
|
||||
wrappers.append(wrapperDef)
|
||||
repls = self.repls.copy()
|
||||
repls['imports'] = '\n'.join(imports)
|
||||
|
|
|
@ -13,7 +13,7 @@ class PloneInstaller:
|
|||
installed or uninstalled (in the Plone configuration interface).'''
|
||||
def __init__(self, reinstall, productName, ploneSite, minimalistPlone,
|
||||
appClasses, appClassNames, allClassNames, catalogMap, applicationRoles,
|
||||
defaultAddRoles, workflows, appFrontPage, ploneStuff):
|
||||
defaultAddRoles, workflows, appFrontPage, showPortlet, ploneStuff):
|
||||
self.reinstall = reinstall # Is it a fresh install or a re-install?
|
||||
self.productName = productName
|
||||
self.ploneSite = ploneSite
|
||||
|
@ -32,6 +32,7 @@ class PloneInstaller:
|
|||
# used by the content type)
|
||||
self.appFrontPage = appFrontPage # Does this app define a site-wide
|
||||
# front page?
|
||||
self.showPortlet = showPortlet # Must we show the application portlet?
|
||||
self.ploneStuff = ploneStuff # A dict of some Plone functions or vars
|
||||
self.toLog = StringIO()
|
||||
self.typeAliases = {'sharing': '', 'gethtml': '',
|
||||
|
@ -257,8 +258,8 @@ class PloneInstaller:
|
|||
nvProps.manage_changeProperties(**{'idsNotToList': current})
|
||||
|
||||
# Remove workflow for the tool
|
||||
wfTool = self.ploneSite.portal_workflow
|
||||
wfTool.setChainForPortalTypes([self.toolName], '')
|
||||
#wfTool = self.ploneSite.portal_workflow
|
||||
#wfTool.setChainForPortalTypes([self.toolName], '')
|
||||
|
||||
# Create the default flavour
|
||||
self.tool = getattr(self.ploneSite, self.toolInstanceName)
|
||||
|
@ -350,17 +351,19 @@ class PloneInstaller:
|
|||
# No portal_css registry
|
||||
pass
|
||||
|
||||
def installPortlet(self):
|
||||
'''Adds the application-specific portlet and configure other Plone
|
||||
portlets if relevant.'''
|
||||
def managePortlets(self):
|
||||
'''Shows or hides the application-specific portlet and configures other
|
||||
Plone portlets if relevant.'''
|
||||
portletName= 'here/%s_portlet/macros/portlet' % self.productName.lower()
|
||||
site = self.ploneSite
|
||||
# This is the name of the application-specific portlet
|
||||
leftPortlets = site.getProperty('left_slots')
|
||||
if not leftPortlets: leftPortlets = []
|
||||
else: leftPortlets = list(leftPortlets)
|
||||
if portletName not in leftPortlets:
|
||||
|
||||
if self.showPortlet and (portletName not in leftPortlets):
|
||||
leftPortlets.insert(0, portletName)
|
||||
if not self.showPortlet and (portletName in leftPortlets):
|
||||
leftPortlets.remove(portletName)
|
||||
# Remove some basic Plone portlets that make less sense when building
|
||||
# web applications.
|
||||
portletsToRemove = ["here/portlet_navigation/macros/portlet",
|
||||
|
@ -402,7 +405,7 @@ class PloneInstaller:
|
|||
self.installRolesAndGroups()
|
||||
self.installWorkflows()
|
||||
self.installStyleSheet()
|
||||
self.installPortlet()
|
||||
self.managePortlets()
|
||||
self.finalizeInstallation()
|
||||
self.log("Installation of %s done." % self.productName)
|
||||
return self.toLog.getvalue()
|
||||
|
|
|
@ -533,6 +533,10 @@ class AbstractMixin:
|
|||
self.appyWrapper = self.wrapperClass(self)
|
||||
return self.appyWrapper
|
||||
|
||||
def appy(self):
|
||||
'''Nice alias to the previous method.'''
|
||||
return self._appy_getWrapper(force=True)
|
||||
|
||||
def _appy_getSourceClass(self, fieldName, baseClass):
|
||||
'''We know that p_fieldName was defined on Python class p_baseClass or
|
||||
one of its parents. This method returns the exact class (p_baseClass
|
||||
|
|
|
@ -16,13 +16,14 @@ appClasses = <!appClasses!>
|
|||
appClassNames = [<!appClassNames!>]
|
||||
allClassNames = [<!allClassNames!>]
|
||||
workflows = {<!workflows!>}
|
||||
showPortlet = <!showPortlet!>
|
||||
# ------------------------------------------------------------------------------
|
||||
def install(self, reinstall=False):
|
||||
'''Installation of product "<!applicationName!>"'''
|
||||
ploneInstaller = PloneInstaller(reinstall, "<!applicationName!>", self,
|
||||
<!minimalistPlone!>, appClasses, appClassNames, allClassNames,
|
||||
catalogMap, applicationRoles, defaultAddRoles, workflows,
|
||||
<!appFrontPage!>, globals())
|
||||
<!appFrontPage!>, showPortlet, globals())
|
||||
return ploneInstaller.install()
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -31,6 +32,6 @@ def uninstall(self, reinstall=False):
|
|||
ploneInstaller = PloneInstaller(reinstall, "<!applicationName!>", self,
|
||||
<!minimalistPlone!>, appClasses, appClassNames, allClassNames,
|
||||
catalogMap, applicationRoles, defaultAddRoles, workflows,
|
||||
<!appFrontPage!>, globals())
|
||||
<!appFrontPage!>, showPortlet, globals())
|
||||
return ploneInstaller.uninstall()
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue