I'm an extremely experienced object technologist just getting into Zope. The Zope Book (p. 211) says that it's not possible to change the base classes of a ZClass. The wording and context are a bit ambiguous, so I'm not entirely sure, but the obvious reading is that once you've defined a ZClass you cannot add, remove, or replace any of its base classes. Is this true? Or does it just mean "not through the techniques being discussed in that part of the book"? What do I do if I've been developing a ZClass and decide I need to add (or remove) some functionality through base classes? For example, suppose I want to add persistence later on? Is the answer different if I don't have any instances I need to keep? Is there a way to export a ZClass to an editable text format, so I could delete it from Zope, make the changes, then reimport it?
Hi Mitchell, There is no way via the management interface to reset the base classes of a ZClass. This is why it's usually a good idea to have the ZClass derive from a single Python base class and do all subclassing there. ZClasses which subclass other ZClasses (or more than one Python base class) are difficult to rebase. There is also an (undocumented) method of all ZClass objects named (somewhat embarassingly) _setBasesHoldOnToYourButts which performs base class rejiggering that you should be able to find information about pretty readily via a Google search. Note also that the linkage between instances and their ZClasses is the ZClass class id, which is a string and is modifiable through the properties view of the ZClass itself. If you create a new ZClass and set its base classes properly, then delete the "old" ZCLass (which we'll assume has instances associated with it for purposes of this description), and set the new ZCLass' classid to what the old one used to be, I *think* you'll be OK. This is the hard way to rebase. There is no human-friendly text serialization of ZClass objects, although you can export to XML via the export interface... some people consider that friendly enough (I don't). This capability is something we'd really like to have, and there is a proposal on http://dev.zope.org to do this named something like FilesystemSerialization or somesuch. HTH, - C Mitchell Model wrote:
I'm an extremely experienced object technologist just getting into Zope. The Zope Book (p. 211) says that it's not possible to change the base classes of a ZClass. The wording and context are a bit ambiguous, so I'm not entirely sure, but the obvious reading is that once you've defined a ZClass you cannot add, remove, or replace any of its base classes.
Is this true? Or does it just mean "not through the techniques being discussed in that part of the book"? What do I do if I've been developing a ZClass and decide I need to add (or remove) some functionality through base classes? For example, suppose I want to add persistence later on? Is the answer different if I don't have any instances I need to keep? Is there a way to export a ZClass to an editable text format, so I could delete it from Zope, make the changes, then reimport it?
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Chris McDonough Zope Corporation http://www.zope.org http://www.zope.com """ Killing hundreds of birds with thousands of stones """
but the obvious reading is that once you've defined a ZClass you cannot add, remove, or replace any of its base classes.
Is this true? Or does it just mean "not through the techniques being discussed in that part of the book"?
Although I've never done it, I understand that there is a (very much unsupported) way to change the base classes of a ZClass. There's a Howto on zope.org about it at http://www.zope.org/Members/AlexR/ChangingBaseClasses There is also dicussion about it somewhere on the list. --jcc (kaboom!)
Try this, but I did not test and the author says it may be dangerous for your ZODB. http://www.zope.org/Members/AlexR/ChangingBaseClasses You can export a ZClass to XML but I did not try too... But AFAIK there's no doc/DTD about this XML. The base classes appear in the XML. Please feedback if you succeeded. Unfortunately, I only got a production server (no development server) and I can't take such risks at the moment. Cheers --Gilles ----- Original Message ----- From: "Mitchell Model" <mlm@acm.org> To: <zope@zope.org> Sent: Friday, August 17, 2001 3:59 PM Subject: [Zope] changing ZClass bases
I'm an extremely experienced object technologist just getting into Zope. The Zope Book (p. 211) says that it's not possible to change the base classes of a ZClass. The wording and context are a bit ambiguous, so I'm not entirely sure, but the obvious reading is that once you've defined a ZClass you cannot add, remove, or replace any of its base classes.
Is this true? Or does it just mean "not through the techniques being discussed in that part of the book"? What do I do if I've been developing a ZClass and decide I need to add (or remove) some functionality through base classes? For example, suppose I want to add persistence later on? Is the answer different if I don't have any instances I need to keep? Is there a way to export a ZClass to an editable text format, so I could delete it from Zope, make the changes, then reimport it?
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (4)
-
Chris McDonough -
Gilles Lenfant -
J. Cameron Cooper -
Mitchell Model