[Checkins] SVN: zodbupdate/branches/sylvain-persistent-load/src/zodbupdate/serialize.py More error tolerant for broken and not renamed class.
Sylvain Viollon
sylvain at infrae.com
Wed Jan 6 12:52:24 EST 2010
Log message for revision 107749:
More error tolerant for broken and not renamed class.
Changed:
U zodbupdate/branches/sylvain-persistent-load/src/zodbupdate/serialize.py
-=-
Modified: zodbupdate/branches/sylvain-persistent-load/src/zodbupdate/serialize.py
===================================================================
--- zodbupdate/branches/sylvain-persistent-load/src/zodbupdate/serialize.py 2010-01-06 17:29:23 UTC (rev 107748)
+++ zodbupdate/branches/sylvain-persistent-load/src/zodbupdate/serialize.py 2010-01-06 17:52:24 UTC (rev 107749)
@@ -21,6 +21,10 @@
logger = logging.getLogger('zodbupdate')
+def isbroken(symb):
+ return isinstance(symb, types.TypeType) and Broken in symb.__mro__
+
+
class ZODBReference:
"""Class to remenber reference we don't want to touch.
"""
@@ -58,7 +62,7 @@
return self.__changes[symb_info]
else:
symb = find_global(*symb_info)
- if isinstance(symb, types.ClassType) and issubclass(symb, Broken):
+ if isbroken(symb):
logger.warning(u'Warning: Missing factory for %s' %
u' '.join(symb_info))
elif hasattr(symb, '__name__') and hasattr(symb, '__module__'):
@@ -125,9 +129,14 @@
about a renamed class.
"""
if isinstance(class_meta, tuple):
- klass_info, args = class_meta
- if isinstance(klass_info, tuple):
- return self.__update_symb(klass_info), args
+ symb, args = class_meta
+ if isbroken(symb):
+ symb_info = (symb.__module__, symb.__name__)
+ logger.warning(u'Warning: Missing factory for %s' %
+ u' '.join(symb_info))
+ return (symb_info, args)
+ elif isinstance(symb, tuple):
+ return self.__update_symb(symb), args
return class_meta
def rename(self, input_file):
@@ -149,8 +158,13 @@
output_file = cStringIO.StringIO()
pickler = self.__pickler(output_file)
- pickler.dump(class_meta)
- pickler.dump(data)
+ try:
+ pickler.dump(class_meta)
+ pickler.dump(data)
+ except cPickle.PicklingError:
+ # Could not pickle that record, likely due to a broken
+ # class ignore it.
+ return None
output_file.truncate()
return output_file
More information about the checkins
mailing list