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):

Attributes added to product code are not automatically present in the objects defined by that code, only those created by that code. Methods, however, will be present on all instances of a given class. I won't bother to connect the dots for you.


Are you sure that you have a product for all those potential orphans out there? Otherwise, the above won't work: you'll need to look for distinct signature somehow, presuming those objects even function: I don't know how true orphans behave.

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

I'll trust that your __dict__ stuff up there works: never tried it myself.


--jcc

--
"My point and period will be throughly wrought,
Or well or ill, as this day's battle's fought."



_______________________________________________
Zope-Dev maillist - [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
** 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