[Zope] Re: ZClass Base Class (QUEST)

Olivier Deckmyn odeckmyn.list@teaser.fr
Tue, 14 Mar 2000 15:14:02 +0100


[Sorry, I pressed the wrong key with my last message ; so here it is :]
Thanx Alex !

I've been fighting a little with the URL, but I got it  :)

For thoose who would have difficulties (like I've had!) here is the source
(should be zc.py) :

#!/dev/null
#
# (c) 1999 M.T.G. Handelsges.m.b.H.
#
# This module is only an experimental Extension module to play around with
ZClass internals.
#

import string

def fetchzclass(REQUEST,prefix=""):
    rg=REQUEST.get
    PARENTS=rg("PARENTS")
    product=rg(prefix+"product")
    zclass=rg(prefix+"zclass")
    app=PARENTS[-1]
    prod=getattr(app.Control_Panel.Products,product)
    zc=getattr(prod,zclass)
    return zc

def strbases(zc):
    r=[]
    for i in zc._zbases:
 r.append(str(i))
    return string.join(r,"\n")

def show(self,REQUEST):
    "This shows the bases of zclass in product."
    zc=fetchzclass(REQUEST)
    return strbases(zc)

def copybases(self,REQUEST):
    "this copies the bases from class srczclass in srcproduct to dstzclass
in dstproduct."
    src_class=fetchzclass(REQUEST,"src")
    dst_class=fetchzclass(REQUEST,"dst")
    dst_class._setBasesHoldOnToYourButts(src_class._zbases[1:])
    rg=REQUEST.get
    get_transaction().note("Copied baseclasses from %s[%s] to %s[%s]." %
      (rg("srcproduct"),rg("srczclass"),rg("dstproduct"),rg("dstzclass")))
    return strbases(dst_class)

Here is the doc (still from Andreas Kostyrka andreas@mtg.co.at):

Well, install the attached zc.py in your Externals directory. Add
external methods zc_copybases and zc_show (mapped to zc.py/copybases
and zc.py/show) somewhere in your ZOPE. For demonstration I assume
it's in your root folder, and your zope server is called
http://myzope/.

Well, then use your browser to visit the following URLs (this does
more or less exactly what the above python magic does):

http://myzope/zc_show?zclass=YourZClass&product=YourProduct
http://myzope/zc_show?zclass=TempZClass&product=YourProduct

   This shows you the baseclasses of the two Z classes.

http://myzope/zc_copybases?
srczclass=TempZClass&srcproduct=YourProduct&
dstzclass=YourZClass&dstproduct=YourProduct

   (This should be a one line URL.)
   This does the voodoo magic above. And completly without shutting down
your ZOPE, and
   it does even comment the transaction nicely. (Interesting question if it
is undoable.)

And yes, the attached file is twice unsupported ;)
1.) The voodoo is not supported by Digital Creations, so it may change
    at any time.
2.) The external module is not supported by MTG, as its voodoo coefficient
    is to high.

Andreas


----- Message d'origine -----
De : Alexandre Ratti <alex@gabuzomeu.net>
À : <zope@zope.org>
Cc : Oscar Picasso <picasso@videotron.ca>; Olivier Deckmyn
<odeckmyn.list@teaser.fr>
Envoyé : mardi 14 mars 2000 13:03
Objet : Re: ZClass Base Class (QUEST)


> Hello,
>
>
> there used to be a way to change the base classes for a ZClass. It's
> documented here:
>
> <http://lists.zope.org/pipermail/zope-dev/1999-August/001288.html>
>
> I haven't used it recently. It worked for me several time in Zope 2.1.1.
>
> Make sure you backup your database before trying it.
>
>
> Alexandre
>
>
> At 12:00 10/03/2000 -0800, you wrote:
> >From: Oscar Picasso <picasso@videotron.ca>
> >Subject: Re: [Zope] ZClass Base Class (QUEST)
> >To: Olivier Deckmyn <odeckmyn.list@teaser.fr>,
> >
> >As far as I know, I don't thing it's possible in Zope. I'm very interesed
in a
> >way to do that
> <snip>
>
> >On Fri, 10 Mar 2000, Olivier Deckmyn wrote:
> > > Is it possible to change the base classes of a ZClass ?
> > >
> > > Even if there is no instances of this ZClass yet ?
> > >
> > > thx !
> > >
>
>