Re: [Zope-dev] CatalogAware must come before ObjectManager
On Thu, 5 Aug 1999, Michel Pelletier wrote:
It is possible, but only from python, and it is a *real* hack. Doing this is completely unsupported. I might get shot for revealing the technique.
Well, so it may be well, that I'm far far away on the other side of the big pond ;) Actually, if you need this, I might send you an image of my person, so you can print it out and play Darts. But then, perhaps I should just write a special Emacs mode for editing python source, and enforce it's usage at Digital Creations: As a special feature, this mode would treat lines the contain the keyword "class" as readonly. Yep. And if you want to change the base classes afterwards, you just delete the .py file and type it from the beginning.
Given a Product called 'YourProduct' that contains a Zclass called 'YourZClass' that you want to 'rebase', first, create a temporary ZClass called 'TempZClass' in the same product. 'TempZClass' should be built with the new order or types of subclasses that you want 'YourZClass' to have. Note that 'TempZClass' need not have anything in it, it just needs to subclass the right classes.
Shut down Zope, run python1.5.2 in your lib/python directory, and execute the following code:
import Zope p = Zope.app().Control_Panel.Products.YourProduct p <Product instance at 849de28> p.YourZClass._setBasesHoldOnToYourButts(p.TempZClass._zbases[1:]) get_transaction().commit()
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 -- Andreas Kostyrka | andreas@mtg.co.at phone: +43/1/7070750 | phone: +43/676/4091256 MTG Handelsges.m.b.H. | fax: +43/1/7065299 Raiffeisenstr. 16/9 | 2320 Zwoelfaxing AUSTRIA
participants (1)
-
Andreas Kostyrka