[Erp5-report] r42958 nicolas.dumazet - /erp5/trunk/products/ERP5/Document/BusinessTemplate.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Feb 3 04:53:14 CET 2011
Author: nicolas.dumazet
Date: Thu Feb 3 04:53:14 2011
New Revision: 42958
URL: http://svn.erp5.org?rev=42958&view=rev
Log:
forcibly migrate DocumentTemplateItem (PathTemplateItems, etc)
to portal type classes if possible.
It involves for instance Delivery Builders, that are stored
as Products.ERP5.Document.SimulatedDeliveryBuilder, and are
out of reach of our automatic migration from ERP5Type.Document...
Modified:
erp5/trunk/products/ERP5/Document/BusinessTemplate.py
Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=42958&r1=42957&r2=42958&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] Thu Feb 3 04:53:14 2011
@@ -546,6 +546,23 @@ class BaseTemplateItem(Implicit, Persist
def importFile(self, bta, **kw):
bta.importFiles(item=self)
+ def migrateToPortalTypeClass(self, obj):
+ klass = obj.__class__
+ if klass.__module__ == 'erp5.portal_type':
+ return obj
+ portal_type = getattr(aq_base(obj), 'portal_type', None)
+ if portal_type is None:
+ portal_type = getattr(klass, 'portal_type', None)
+
+ if portal_type is None:
+ # ugh?
+ return obj
+ import erp5.portal_type
+ newklass = getattr(erp5.portal_type, portal_type)
+ assert klass != newklass
+ obj.__class__ = newklass
+ return obj
+
def removeProperties(self, obj, export):
"""
Remove unneeded properties for export
@@ -569,6 +586,8 @@ class BaseTemplateItem(Implicit, Persist
attr_set.update(('_arg', 'template'))
elif interfaces.IIdGenerator.providedBy(obj):
attr_set.update(('last_max_id_dict', 'last_id_dict'))
+ else:
+ obj = self.migrateToPortalTypeClass(obj)
for attr in obj.__dict__.keys():
if attr in attr_set or attr.startswith('_cache_cookie_'):
More information about the Erp5-report
mailing list