[Zope] Adding another base class to an existing ZClass

Kevin Dangoor kid@kendermedia.com
Mon, 10 Jan 2000 09:52:52 -0500


I have not tried the wildly unsupported method... I'm not brave enough. I
have, however, used the method that Gregor describes. It is a little
tedious, but it works just fine. Broken down step-by-step, I think this is
what I've done:

1) Rename the old classes and their metatypes to something like MyClass2,
MyType2
2) Create a new ZClass with the proper base classes.
3) Start copying and pasting your methods and such... rebuild your
propertysheets. This is the tedious part. It's probably a good idea to make
sure you look at every tab in the management interface to make sure you
don't miss something.
4) Copy your original ZClass' class ID to the clipboard. Then change the
class ID to something else. (I typically just add an extra = on the end)
5) Change the new ZClass' class ID to the one on the clipboard.

Voila! New ZClass.

I think Chris' suggestion from his next message (creating a Python base
class) sounds really dandy. But, you'll probably want to use the above steps
to get that base class into your existing ZClasses...

Kevin

----- Original Message -----
From: "Chris McDonough" <chrism@digicool.com>
To: "Gregor" <vorlon@iglou.com>
Cc: <zope@zope.org>; <stevej@parlant.com>
Sent: Sunday, January 09, 2000 11:00 PM
Subject: Re: [Zope] Adding another base class to an existing ZClass


> AFAIK, there is no approved way to add a base class to an existing
> ZClass.  I've heard from other people at DC that it is possible, but
> it's a "hold on to your butts" experience.  That said, I have no idea
> whether Gregor's method will work or not.
>
> Gregor wrote:
> >
> > ----- Original Message -----
> > From: "Steve Jibson" <stevej@parlant.com>
> > To: <zope@zope.org>
> > Sent: Friday, January 07, 2000 6:22 PM
> > Subject: [Zope] Adding another base class to an existing ZClass
> >
> > > I've spent many hours working on a ZClass (with multiple sub-zclasses,
> > > etc.), and now I've decided that I should have inherited from Folder
as
> > > well as ObjectManager when I created the ZClass.  Is there a way to
add
> > > a base class to the base class list of an existing ZClass, or do I
need
> > > to start all over?
> >
> > Did anyone ever reply to this, or are you still trying to figure it out?
> >
> > I've seen something in the Zope how-tos or guides about the "class id"
field
> > on the "basic" tab of the ZClass, and swapping out one ZClass for
another.
> >
> > I THINK the basic idea is that you would copy or export everything you
want to
> > keep (such as child ZClasses and methods) to a safe place, copy the
ZClass's
> > class id to a file somewhere, then delete the ZClass.
> >
> > Create a new one with the same id, deriving from whatever you need.
Then
> > replace the new class's id with the one you saved in the file.  Finally,
> > re-import or paste the things you needed to keep from the old class.
> >
> > I have not tested the above and have no idea if it would work, so I
really
> > recommend backing your database up before you try it.  If you do try it,
let
> > me know how it works out.