Commit b454610f authored by Romain Courteaud's avatar Romain Courteaud

Add method getDefaultModule and getDefaultModuleId.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2303 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 68213530
......@@ -445,6 +445,30 @@ class ERP5Site ( CMFSite, FolderMixIn ):
"""
return self._getPortalConfiguration('portal_tab_base_category_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getDefaultModuleId')
def getDefaultModuleId(self, portal_type):
"""
Return default module id where a object with portal_type can be created
"""
# XXX very dummy method, but it works with today name convention
module_name = portal_type.lower().replace(' ','_')
portal_object = self
if not hasattr(portal_object, module_name):
module_name += '_module'
if not hasattr(portal_object, module_name):
LOG('ERP5Site, getDefaultModuleId',0,'Unable to find default module for portal_type: %s' % portal_type )
raise
return module_name
security.declareProtected(Permissions.AccessContentsInformation, 'getDefaultModule')
def getDefaultModule(self, portal_type):
"""
Return default module where a object with portal_type can be created
"""
return getattr(self, self.getDefaultModuleId(portal_type), None)
security.declareProtected(Permissions.AddPortalContent, 'newContent')
def newContent(self, id=None, portal_type=None, immediate_reindex=0, **kw):
"""
......
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