[Zope] Python Question: Morphing Classes?
Johan Carlsson [EasyPublisher]
johanc@easypublisher.com
Mon, 09 Dec 2002 23:57:45 +0100
In lack for other Python mailing lists I send my question here
(there ought to be someone with a bit of python-zen here ;-)
I'm have a bit of a problem because I need to copy one object in
the ZODB. Now the copy-and-paste support of Zope will not do
it because it actually export/imports the object including all
its sub object. So I have abandoned that idea (after an interesting
attempt to export only the object (based on their oids), which
was bound to fail.
Anyway, there isn't any generic way to create an arbitrary product instance.
Because if I could do that I could copy all the data into the new object,=
but
I need to be able to handle any addable Zope object and they all got=
different
init-methods requiring arguments.
But I have tried another thing:
Creating an instance (a) of the class C: pass, I can set the
a.__class__=3DA (where A is another class), a will report that it
is a instance of A and it will have all of A's class context.
This look like a possible, even if not so less hackerish, way around my=20
problem.
Are there any traps I could fall into here?
Regards,
Johan Carlsson
--=20
Torped Strategi och Kommunikation AB
Johan Carlsson
johanc@easypublisher.com
Mail:
Birkagatan 9
SE-113 36 Stockholm
Sweden
Visit:
V=E4stmannagatan 67, Stockholm, Sweden
Phone +46-(0)8-32 31 23
Fax +46-(0)8-32 31 83
Mobil +46-(0)70-558 25 24
http://www.easypublisher.com
http://www.torped.se