Commit ed909147 authored by Nicolas Dumazet's avatar Nicolas Dumazet

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...


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42958 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fc4a0e18
......@@ -546,6 +546,23 @@ class BaseTemplateItem(Implicit, Persistent):
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, Persistent):
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_'):
......
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