Commit be17e8bd authored by Arnaud Fontaine's avatar Arnaud Fontaine

Do not update automatically the component module registry for reliability's sake.

Instead, reset it everytime because after all, contentValues() is
rather fast even with 1000 objects.
parent cff4d9e5
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>state_change[\'object\'].addToRegistry()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>addToRegistry</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>state_change[\'object\'].deleteFromRegistry()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>deleteFromRegistry</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -46,7 +46,7 @@
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string>deleteFromRegistry</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -46,7 +46,7 @@
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string>addToRegistry</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
......
2012-02-21 arnaud.fontaine
* Do not update automatically the component module registry for reliability's sake.
2012-02-20 arnaud.fontaine
* Add Business Template action to import Document and Extensions automatically after giving the version.
......
41003
\ No newline at end of file
41004
\ No newline at end of file
......@@ -98,31 +98,6 @@ class Component(Base):
return []
security.declareProtected(Permissions.ModifyPortalContent, 'addToRegistry')
def addToRegistry(self):
"""
Add the Component to its appropriate module registry
"""
namespace_fullname = self._getDynamicModuleNamespace()
namespace_module = __import__(namespace_fullname, {}, {},
fromlist=[namespace_fullname])
reference = self.getReference()
namespace_module._registry_dict.setdefault(
reference, {})[self.getVersion()] = self
security.declareProtected(Permissions.ModifyPortalContent,
'deleteFromRegistry')
def deleteFromRegistry(self):
"""
Delete the Component from its appropriate module registry
"""
namespace_fullname = self._getDynamicModuleNamespace()
namespace_module = __import__(namespace_fullname, {}, {},
fromlist=[namespace_fullname])
del namespace_module._registry_dict[self.getReference()]
def _setTextContent(self, text_content):
"""
When the validation state is already 'validated', set the new value to
......
......@@ -112,6 +112,7 @@ class ComponentTool(BaseTool):
except AttributeError:
pass
else:
module._resetRegistry()
self._resetModule(module)
type_tool.resetDynamicDocumentsOnceAtTransactionBoundary()
......
......@@ -64,7 +64,7 @@ class ComponentDynamicPackage(ModuleType):
# Necessary otherwise imports will fail because an object is considered a
# package only if __path__ is defined
__path__ = []
__registry_dict = None
__registry_dict = {}
def __init__(self, namespace, portal_type):
super(ComponentDynamicPackage, self).__init__(namespace)
......@@ -93,7 +93,7 @@ class ComponentDynamicPackage(ModuleType):
like erp5.component.extension.VERSION.REFERENCE perhaps but there should
be a a way to specify priorities such as portal_skins maybe?
"""
if self.__registry_dict is None:
if not self.__registry_dict:
try:
component_tool = getSite().portal_components
# XXX-arnau: When installing ERP5 site, erp5_core_components has not
......@@ -117,6 +117,9 @@ class ComponentDynamicPackage(ModuleType):
return self.__registry_dict
def _resetRegistry(self):
self.__registry_dict.clear()
def find_module(self, fullname, path=None):
# Ignore imports with a path which are filesystem-only and any
# absolute imports which does not start with this package prefix,
......
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