[Zope] how to change the 'Zope' realm/resource??

Brian Lloyd Brian@digicool.com
Wed, 13 Sep 2000 11:58:01 -0400


> Steve Drees wrote:
> > WHat if we want to change the realm dependent on the folder?
> > 
> > I.e. Is there a way to change this at run-time?
> 
> I'd love to know the answer to this one too :-)
> 
> Chris

The realm is currently an attribute of the RESPONSE object. 
There is a 'realm' class attribute which provides the 
default realm - you could either somehow change this as 
needed (which may be sort of hard, especially since 
unauthorized usually gets raised before user code ever 
gets run), or change the default class attribute.

You could change the default class attribute by either:

  - hacking the code (bleah)

  - or maybe better, create a "product" in your lib/python/Products
    (say RealmHack). The product dir would only have an __init__.py 
    file that looked like:

import ZPublisher.HTTPResponse

ZPublisher.HTTPResponse.HTTPResponse.realm='whatever'

...which would allow you change the default class attr 
without hacking the code itself. When your product gets 
imported (at startup time), your realm would be used.

Note that wouldn't help with "per folder" realm changing. 
I'm open to suggestions on that. One way I suppose would 
be to subclass Folder and implement an extended version 
of __bobo_traverse__ that changed the realm upon traversal.

Brian Lloyd        brian@digicool.com
Software Engineer  540.371.6909              
Digital Creations  http://www.digicool.com