[Erp5-report] r39708 jm - in /erp5/trunk/products: ERP5/Document/ ERP5/tests/ ERP5/tests/te...
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Oct 29 18:44:03 CEST 2010
Author: jm
Date: Fri Oct 29 18:44:02 2010
New Revision: 39708
URL: http://svn.erp5.org?rev=39708&view=rev
Log:
Sort portal types to install according to their dependencies
Added:
erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/PortalTypeTemplateItem/portal_types/Foo%20Type.xml
Removed:
erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/PathTemplateItem/some_foo.xml
Modified:
erp5/trunk/products/ERP5/Document/BusinessTemplate.py
erp5/trunk/products/ERP5/tests/testBusinessTemplate.py
erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/PortalTypeTemplateItem/portal_types/Foo.xml
erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/bt/template_path_list
erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/bt/template_portal_type_id_list
erp5/trunk/products/ERP5Type/Utils.py
Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=39708&r1=39707&r2=39708&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] Fri Oct 29 18:44:02 2010
@@ -56,7 +56,7 @@ from Products.ERP5Type.Utils import read
from Products.ERP5Type.Utils import readLocalTest, \
writeLocalTest, \
removeLocalTest
-from Products.ERP5Type.Utils import convertToUpperCase
+from Products.ERP5Type.Utils import convertToUpperCase, PersistentMigrationMixin
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Type.dynamic.portal_type_class import synchronizeDynamicModules
@@ -954,6 +954,12 @@ class ObjectTemplateItem(BaseTemplateIte
**original_reindex_parameters)
return original_reindex_parameters
+ def _getObjectKeyList(self):
+ # sort to add objects before their subobjects
+ keys = self._objects.keys()
+ keys.sort()
+ return keys
+
def install(self, context, trashbin, **kw):
self.beforeInstall()
update_dict = kw.get('object_to_update')
@@ -981,12 +987,10 @@ class ObjectTemplateItem(BaseTemplateIte
groups = {}
old_groups = {}
portal = context.getPortalObject()
- # sort to add objects before their subobjects
- keys = self._objects.keys()
- keys.sort()
# set safe activities execution order
original_reindex_parameters = self.setSafeReindexationMode(context)
- for path in keys:
+ object_key_list = self._getObjectKeyList()
+ for path in object_key_list:
if update_dict.has_key(path) or force:
# get action for the oject
action = 'backup'
@@ -1225,7 +1229,7 @@ class ObjectTemplateItem(BaseTemplateIte
if getattr(aq_base(container), 'objectIds', None) is not None:
fillRecursivePathList(['%s/%s' % (from_path, sub_content_id) for\
sub_content_id in container.objectIds()])
- fillRecursivePathList(self._objects.keys())
+ fillRecursivePathList(object_key_list)
for recursive_path in recursive_path_list:
if recursive_path in update_dict:
action = update_dict[recursive_path]
@@ -1899,6 +1903,31 @@ class PortalTypeTemplateItem(ObjectTempl
self._objects[relative_url] = obj
obj.wl_clearLocks()
+ def _getObjectKeyList(self):
+ # Sort portal types to install according to their dependencies
+ object_key_list = self._objects.keys()
+ path_dict = dict(x.split('/')[1:] + [x] for x in object_key_list)
+ cache = {}
+ def solveDependency(path):
+ score = cache.get(path)
+ if score is None:
+ obj = self._objects[path]
+ klass = obj.__class__
+ if klass.__module__.startswith('Products.ERP5Type.Document.'):
+ portal_type = obj.portal_type
+ obj._p_deactivate()
+ else:
+ portal_type = klass.__name__
+ depend = path_dict.get(portal_type)
+ cache[path] = score = depend and 1 + solveDependency(depend)[0] or 0
+ return score, path
+ PersistentMigrationMixin._no_migration += 1
+ try:
+ object_key_list.sort(key=solveDependency)
+ finally:
+ PersistentMigrationMixin._no_migration -= 1
+ return object_key_list
+
# XXX : this method is kept temporarily, but can be removed once all bt5 are
# re-exported with separated workflow-chain information
def install(self, context, trashbin, **kw):
Modified: erp5/trunk/products/ERP5/tests/testBusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testBusinessTemplate.py?rev=39708&r1=39707&r2=39708&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testBusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testBusinessTemplate.py [utf8] Fri Oct 29 18:44:02 2010
@@ -6667,7 +6667,7 @@ class TestBusinessTemplate(ERP5TypeTestC
from Products.ERP5.Document.BusinessTemplate import BaseTemplateItem
portal = self.portal
BaseTemplateItem_removeProperties = BaseTemplateItem.removeProperties
- object_id_list = 'old_file', 'some_file', 'some_foo'
+ object_id_list = 'old_file', 'some_file'
marker_list = []
def removeProperties(self, obj, export):
# Check it works if the object is modified during install.
Removed: erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/PathTemplateItem/some_foo.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/PathTemplateItem/some_foo.xml?rev=39707&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/PathTemplateItem/some_foo.xml [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/PathTemplateItem/some_foo.xml (removed)
@@ -1,16 +0,0 @@
-<?xml version="1.0"?>
-<ZopeData>
- <record id="1" aka="AAAAAAAAAAE=">
- <pickle>
- <global name="Foo" module="erp5.portal_type"/>
- </pickle>
- <pickle>
- <dictionary>
- <item>
- <key> <string>id</string> </key>
- <value> <string>some_foo</string> </value>
- </item>
- </dictionary>
- </pickle>
- </record>
-</ZopeData>
Added: erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/PortalTypeTemplateItem/portal_types/Foo%20Type.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/PortalTypeTemplateItem/portal_types/Foo%2520Type.xml?rev=39708&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/PortalTypeTemplateItem/portal_types/Foo%20Type.xml (added)
+++ erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/PortalTypeTemplateItem/portal_types/Foo%20Type.xml [utf8] Fri Oct 29 18:44:02 2010
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<ZopeData>
+ <record id="1" aka="AAAAAAAAAAE=">
+ <pickle>
+ <global name="Base Type" module="erp5.portal_type"/>
+ </pickle>
+ <pickle>
+ <dictionary>
+ <item>
+ <key> <string>id</string> </key>
+ <value> <string>Foo Type</string> </value>
+ </item>
+ <item>
+ <key> <string>portal_type</string> </key>
+ <value> <string>Base Type</string> </value>
+ </item>
+ <item>
+ <key> <string>type_class</string> </key>
+ <value> <string>ERP5TypeInformation</string> </value>
+ </item>
+ </dictionary>
+ </pickle>
+ </record>
+</ZopeData>
Modified: erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/PortalTypeTemplateItem/portal_types/Foo.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/PortalTypeTemplateItem/portal_types/Foo.xml?rev=39708&r1=39707&r2=39708&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/PortalTypeTemplateItem/portal_types/Foo.xml [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/PortalTypeTemplateItem/portal_types/Foo.xml [utf8] Fri Oct 29 18:44:02 2010
@@ -2,58 +2,22 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
- <global name="Base Type" module="erp5.portal_type"/>
+ <global name="Foo Type" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
- <key> <string>content_icon</string> </key>
- <value>
- <none/>
- </value>
- </item>
- <item>
- <key> <string>description</string> </key>
- <value>
- <none/>
- </value>
- </item>
- <item>
- <key> <string>factory</string> </key>
- <value>
- <none/>
- </value>
- </item>
- <item>
<key> <string>id</string> </key>
<value> <string>Foo</string> </value>
</item>
<item>
- <key> <string>init_script</string> </key>
- <value>
- <none/>
- </value>
- </item>
- <item>
- <key> <string>permission</string> </key>
- <value>
- <none/>
- </value>
- </item>
- <item>
<key> <string>portal_type</string> </key>
- <value> <string>Base Type</string> </value>
+ <value> <string>Foo Type</string> </value>
</item>
<item>
<key> <string>type_class</string> </key>
<value> <string>XMLObject</string> </value>
</item>
- <item>
- <key> <string>type_mixin</string> </key>
- <value>
- <tuple/>
- </value>
- </item>
</dictionary>
</pickle>
</record>
Modified: erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/bt/template_path_list
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/bt/template_path_list?rev=39708&r1=39707&r2=39708&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/bt/template_path_list [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/bt/template_path_list [utf8] Fri Oct 29 18:44:02 2010
@@ -1,3 +1,2 @@
old_file
-some_file
-some_foo
\ No newline at end of file
+some_file
\ No newline at end of file
Modified: erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/bt/template_portal_type_id_list
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/bt/template_portal_type_id_list?rev=39708&r1=39707&r2=39708&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/bt/template_portal_type_id_list [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/test_data/test_167_InstanceAndRelatedClassDefinedInSameBT/bt/template_portal_type_id_list [utf8] Fri Oct 29 18:44:02 2010
@@ -1 +1,2 @@
-Foo
\ No newline at end of file
+Foo
+Foo Type
\ No newline at end of file
Modified: erp5/trunk/products/ERP5Type/Utils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Utils.py?rev=39708&r1=39707&r2=39708&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Utils.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Utils.py [utf8] Fri Oct 29 18:44:02 2010
@@ -887,14 +887,14 @@ class PersistentMigrationMixin(object):
It allows us to migrate ERP5Type.Document.XXX.YYY classes to
erp5.portal_type.ZZZ namespace
- Note that migration can be disabled by setting the migrate
- class attribute to 0/False, as all old objects in the system
+ Note that migration can be disabled by setting the '_no_migration'
+ class attribute to a nonzero value, as all old objects in the system
should inherit from this mixin
"""
- migrate = 1
+ _no_migration = 0
def __setstate__(self, value):
- if not PersistentMigrationMixin.migrate:
+ if PersistentMigrationMixin._no_migration:
super(PersistentMigrationMixin, self).__setstate__(value)
return
More information about the Erp5-report
mailing list