From 250b51a05a7ad4c3ec3005f8ad291ec7a2900e4c Mon Sep 17 00:00:00 2001 From: Yoshinori Okuji <yo@nexedi.com> Date: Mon, 26 Apr 2004 15:18:14 +0000 Subject: [PATCH] Sort the list in allowedContentTypes for convenience, and add a new method emptyCache to remake a cache. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@741 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/Document/Folder.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/product/ERP5Type/Document/Folder.py b/product/ERP5Type/Document/Folder.py index e523636d51..eaec7aae44 100755 --- a/product/ERP5Type/Document/Folder.py +++ b/product/ERP5Type/Document/Folder.py @@ -543,9 +543,23 @@ be a problem).""" user = str(_getAuthenticatedUser(self)) portal_type = self.getPortalType() if not cached_allowed_content_types.has_key((portal_type, user)): - cached_allowed_content_types[(portal_type, user)] = CMFBTreeFolder.allowedContentTypes(self) + # Sort the list for convenience -yo + # XXX This is not the best solution, because this does not take account i18n into consideration. + # XXX So sorting should be done in skins, after translation is performed. + def compareTypes(a, b): return cmp(a.title or a.id, b.title or b.id) + type_list = CMFBTreeFolder.allowedContentTypes(self) + type_list.sort(compareTypes) + cached_allowed_content_types[(portal_type, user)] = type_list return cached_allowed_content_types[(portal_type, user)] + # Flush the cache in Menu System + security.declareProtected(Permissions.ManagePortal, 'emptyCache') + def emptyCache( self ): + """ + Empty the cache of allowed content types in the menu system. + """ + cached_allowed_content_types = {} + # Multiple Inheritance Priority Resolution _setProperty = Base._setProperty setProperty = Base.setProperty -- 2.30.9