Over the last month or so, I've rather wonderfully managed to corrupt my ZODB with artifacts of my Currency class that no longer exist.

This is due to:
(i) moving the module to a different package (twice)
(ii) renaming the module
(iii) changing it's inheritance hierarchy (having removed all Zope-awareness from class has caused loads of setstate issues in regard to either __basicnew__ not found, AttributeErrors, and problems with non-derivation from AcquireImplicitWrapper)

I now desperately need to write a parser to convert all of these nasties to ZCurrency types. I've come up with the following ExternalMethod - whereby I've defined a __currency__ attribute in each obselete incantation's product (Currency object's are used in the spirit of DateTime rather than within ObjectManager containment structures):

from Acquisition import aq_base
from Products.BastionBanking.ZCurrency import ZCurrency

def repair(container, counter=0):
   for (k,v) in container.__dict__.items():
       if hasattr(v, '__currency__'):
           setattr(container, k, ZCurrency(v._currency, v._amount))
           counter += 1

   for object in container.objectValues():
       for (k,v) in object.__dict__.items():
           if  hasattr(v, '__currency__'):
               setattr(object, k, ZCurrency(v._currency, v._amount))
               counter += 1
       if hasattr(aq_base(object), 'objectValues'):
           repair(object, counter)
   return counter

However, it doesn't seem to find anything to convert. Does anyone have any ideas?

TIA, Alan

Surf the net and talk on the phone with Xtra Jetstream @ http://www.xtra.co.nz/products/0,,5803,00.html !

Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )

Reply via email to