[Zope] changing ZClass bases

Chris McDonough chrism@zope.com
Fri, 17 Aug 2001 10:15:53 -0400


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 """