[Checkins] SVN: Products.ZCatalog/trunk/src/Products/ZCatalog/Catalog.py avoid data migration in add/del column if there's not data yet
Hano Schlichting
cvs-admin at zope.org
Sun Aug 12 18:55:00 UTC 2012
Log message for revision 127498:
avoid data migration in add/del column if there's not data yet
Changed:
U Products.ZCatalog/trunk/src/Products/ZCatalog/Catalog.py
-=-
Modified: Products.ZCatalog/trunk/src/Products/ZCatalog/Catalog.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/ZCatalog/Catalog.py 2012-08-12 18:34:04 UTC (rev 127497)
+++ Products.ZCatalog/trunk/src/Products/ZCatalog/Catalog.py 2012-08-12 18:54:57 UTC (rev 127498)
@@ -181,12 +181,13 @@
if default_value in (None, ''):
default_value = MV
- pghandler = ZLogHandler(threshold)
- pghandler.init('Adding %s column' % name, len(self))
- for i, (key, value) in enumerate(self.data.iteritems()):
- pghandler.report(i)
- self.data[key] = value + (default_value, )
- pghandler.finish()
+ if len(self):
+ pghandler = ZLogHandler(threshold)
+ pghandler.init('Adding %s column' % name, len(self))
+ for i, (key, value) in enumerate(self.data.iteritems()):
+ pghandler.report(i)
+ self.data[key] = value + (default_value, )
+ pghandler.finish()
self.names = tuple(names)
self.schema = schema
@@ -218,13 +219,14 @@
self.updateBrains()
# remove the column value from each record
- _next_index = _index + 1
- pghandler = ZLogHandler(threshold)
- pghandler.init('Deleting %s column' % name, len(self))
- for i, (key, value) in enumerate(self.data.iteritems()):
- pghandler.report(i)
- self.data[key] = value[:_index] + value[_next_index:]
- pghandler.finish()
+ if len(self):
+ _next_index = _index + 1
+ pghandler = ZLogHandler(threshold)
+ pghandler.init('Deleting %s column' % name, len(self))
+ for i, (key, value) in enumerate(self.data.iteritems()):
+ pghandler.report(i)
+ self.data[key] = value[:_index] + value[_next_index:]
+ pghandler.finish()
def addIndex(self, name, index_type):
"""Create a new index, given a name and a index_type.
More information about the checkins
mailing list