From b454610ff27048bfdd7a887150358fb74373a447 Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Wed, 26 Jan 2005 13:09:20 +0000 Subject: [PATCH] Add method getDefaultModule and getDefaultModuleId. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2303 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/ERP5Site.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/product/ERP5/ERP5Site.py b/product/ERP5/ERP5Site.py index 51f63a7537..3b6ba5eb2c 100755 --- a/product/ERP5/ERP5Site.py +++ b/product/ERP5/ERP5Site.py @@ -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): """ -- 2.30.9