[Erp5-report] r31115 jerome - /erp5/trunk/products/ERP5Type/TranslationProviderBase.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Dec 7 13:47:27 CET 2009


Author: jerome
Date: Mon Dec  7 13:47:26 2009
New Revision: 31115

URL: http://svn.erp5.org?rev=31115&view=rev
Log:
update the docstring of 'updateInitialPropertyTranslationDomainDict' and call
it periodically from getPropertyTranslationDomainDict

Modified:
    erp5/trunk/products/ERP5Type/TranslationProviderBase.py

Modified: erp5/trunk/products/ERP5Type/TranslationProviderBase.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/TranslationProviderBase.py?rev=31115&r1=31114&r2=31115&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/TranslationProviderBase.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/TranslationProviderBase.py [utf8] Mon Dec  7 13:47:26 2009
@@ -16,6 +16,7 @@
 from AccessControl import ClassSecurityInfo
 from Products.CMFCore.Expression import Expression
 from Products.ERP5Type import _dtmldir
+from Products.ERP5Type.Cache import CachingMethod
 
 from Permissions import AccessContentsInformation, ManagePortal, ModifyPortalContent
 from OFS.SimpleItem import SimpleItem
@@ -57,7 +58,8 @@
   security.declarePrivate('updateInitialPropertyTranslationDomainDict')
   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 = {}
 
@@ -78,14 +80,19 @@
       # And store
       self._property_domain_dict = property_domain_dict
 
-  security.declareProtected(AccessContentsInformation, 'getPropertyTranslationDomainDict')
+  security.declareProtected(AccessContentsInformation,
+                            'getPropertyTranslationDomainDict')
   def getPropertyTranslationDomainDict(self):
     """
-    Return all the translation defined by a provider.
-    """
-    # initialize if needed
-    if getattr(self, '_property_domain_dict', None) is None:
+    Return all translations defined by a provider.
+    """
+    # From time to time we'll update property translation domain dict.
+    def _updatePropertyTranslationDomainDict():
       self.updateInitialPropertyTranslationDomainDict()
+    CachingMethod(_updatePropertyTranslationDomainDict,
+      id='%s._updateInitialPropertyTranslationDomainDict' % self.getId(),
+      cache_factory='erp5_ui_long')()
+
     return dict((k, v.__of__(self))
                 for k, v in self._property_domain_dict.iteritems())
 




More information about the Erp5-report mailing list