[Zope-dev] CatalogAware must come before ObjectManager

Andreas Kostyrka andreas@mtg.co.at
Tue, 24 Aug 1999 20:04:33 +0200 (CEST)


  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

---1463811696-1640155869-935517873=:11567
Content-Type: TEXT/PLAIN; charset=US-ASCII

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        




---1463811696-1640155869-935517873=:11567
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="zc.py"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.10.9908242004330.11567@gatekeeper.zwax.mtg.co.at>
Content-Description: ZClass Manipulation methods.
Content-Disposition: attachment; filename="zc.py"

IyEvZGV2L251bGwNCiMNCiMgKGMpIDE5OTkgTS5ULkcuIEhhbmRlbHNnZXMu
bS5iLkguDQojDQojIFRoaXMgbW9kdWxlIGlzIG9ubHkgYW4gZXhwZXJpbWVu
dGFsIEV4dGVuc2lvbiBtb2R1bGUgdG8gcGxheSBhcm91bmQgd2l0aCBaQ2xh
c3MgaW50ZXJuYWxzLg0KIyANCg0KaW1wb3J0IHN0cmluZw0KDQpkZWYgZmV0
Y2h6Y2xhc3MoUkVRVUVTVCxwcmVmaXg9IiIpOg0KICAgIHJnPVJFUVVFU1Qu
Z2V0DQogICAgUEFSRU5UUz1yZygiUEFSRU5UUyIpDQogICAgcHJvZHVjdD1y
ZyhwcmVmaXgrInByb2R1Y3QiKQ0KICAgIHpjbGFzcz1yZyhwcmVmaXgrInpj
bGFzcyIpDQogICAgYXBwPVBBUkVOVFNbLTFdDQogICAgcHJvZD1nZXRhdHRy
KGFwcC5Db250cm9sX1BhbmVsLlByb2R1Y3RzLHByb2R1Y3QpDQogICAgemM9
Z2V0YXR0cihwcm9kLHpjbGFzcykNCiAgICByZXR1cm4gemMNCg0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