Commit 250b51a0 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Sort the list in allowedContentTypes for convenience, and add a new method...

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
parent 5bbd36d8
......@@ -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
......
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