Commit c54b6f1b authored by Jérome Perrin's avatar Jérome Perrin

update the docstring of 'updateInitialPropertyTranslationDomainDict' and call

it periodically from getPropertyTranslationDomainDict


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31115 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 993ff5d9
...@@ -16,6 +16,7 @@ from Products.ERP5Type.Globals import InitializeClass ...@@ -16,6 +16,7 @@ from Products.ERP5Type.Globals import InitializeClass
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
from Products.ERP5Type import _dtmldir from Products.ERP5Type import _dtmldir
from Products.ERP5Type.Cache import CachingMethod
from Permissions import AccessContentsInformation, ManagePortal, ModifyPortalContent from Permissions import AccessContentsInformation, ManagePortal, ModifyPortalContent
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
...@@ -57,7 +58,8 @@ class TranslationProviderBase(object): ...@@ -57,7 +58,8 @@ class TranslationProviderBase(object):
security.declarePrivate('updateInitialPropertyTranslationDomainDict') security.declarePrivate('updateInitialPropertyTranslationDomainDict')
def updateInitialPropertyTranslationDomainDict(self): def updateInitialPropertyTranslationDomainDict(self):
""" """
Create the initial list of association between property and domain name Updates the list of association between property and domain name.
This method must be called anytime new translatable properties are added.
""" """
property_domain_dict = {} property_domain_dict = {}
...@@ -78,14 +80,19 @@ class TranslationProviderBase(object): ...@@ -78,14 +80,19 @@ class TranslationProviderBase(object):
# And store # And store
self._property_domain_dict = property_domain_dict self._property_domain_dict = property_domain_dict
security.declareProtected(AccessContentsInformation, 'getPropertyTranslationDomainDict') security.declareProtected(AccessContentsInformation,
'getPropertyTranslationDomainDict')
def getPropertyTranslationDomainDict(self): def getPropertyTranslationDomainDict(self):
""" """
Return all the translation defined by a provider. Return all translations defined by a provider.
""" """
# initialize if needed # From time to time we'll update property translation domain dict.
if getattr(self, '_property_domain_dict', None) is None: def _updatePropertyTranslationDomainDict():
self.updateInitialPropertyTranslationDomainDict() self.updateInitialPropertyTranslationDomainDict()
CachingMethod(_updatePropertyTranslationDomainDict,
id='%s._updateInitialPropertyTranslationDomainDict' % self.getId(),
cache_factory='erp5_ui_long')()
return dict((k, v.__of__(self)) return dict((k, v.__of__(self))
for k, v in self._property_domain_dict.iteritems()) for k, v in self._property_domain_dict.iteritems())
......
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