Commit 776ca17f authored by Bartek Górny's avatar Bartek Górny

improved getting module for a portal type - in addition to naming convention...

improved getting module for a portal type - in addition to naming convention we look for a module which allows the given type

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11783 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 49f61d11
...@@ -816,12 +816,26 @@ class ERP5Site(FolderMixIn, CMFSite): ...@@ -816,12 +816,26 @@ class ERP5Site(FolderMixIn, CMFSite):
Return default module id where a object with portal_type can Return default module id where a object with portal_type can
be created. be created.
""" """
# Very dummy method, but it works with today name convention. # first try to find by naming convention
module_name = portal_type.lower().replace(' ','_') module_name = portal_type.lower().replace(' ','_')
portal_object = self portal_object = self
if not hasattr(portal_object, module_name): if hasattr(portal_object, module_name):
return module_name
module_name += '_module' module_name += '_module'
if not hasattr(portal_object, module_name): if hasattr(portal_object, module_name):
return module_name
# then look for module where the type is allowed
module_name=MARKER
modlist=[m for m in self.objectIds() if m.endswith('module')]
for mod in modlist:
module=self.restrictedTraverse(mod,MARKER)
if module is MARKER: # we can't access this one
continue
if portal_type in self.portal_types[module.getPortalType()].allowed_content_types:
module_name=mod
break
if module_name is not MARKER:
return module_name
if default is not MARKER: if default is not MARKER:
return default return default
LOG('ERP5Site, getDefaultModuleId', 0, LOG('ERP5Site, getDefaultModuleId', 0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment