Is there a way to get a handle on an existing arbitrary object in the ZODB, let's say index_html in the root, through a pyhton product when it initializes? Roché
Is there a way to get a handle on an existing arbitrary object in the ZODB, let's say index_html in the root, through a pyhton product when it initializes?
Try: index_html = self.unrestrictedTraverse('/index_html) cheers, Chris
=?iso-8859-1?Q?Roch=E9=5FCompaan?= writes:
Is there a way to get a handle on an existing arbitrary object in the ZODB, let's say index_html in the root, through a pyhton product when it initializes?
from Zope import app root= app() index_html= root.index_html This gives you the "bare" object: it lacks the usual "REQUEST" wrapper in its acquisition chain. If you need it, you need a request object, say "R", and call R.traverse(path_to_your_object) There have been rumors on the mailing list (--> archives) that Zope 2.4 would contain a "getrequest" utility to create such a request. There is no such utility in my ZopeCVS. Search the archives. If you can not find anything, report back. I can post a request creation function. Dieter
=?iso-8859-1?Q?Roch=E9=5FCompaan?= writes:
Is there a way to get a handle on an existing arbitrary object in the ZODB, let's say index_html in the root, through a pyhton product when it initializes?
from Zope import app
root= app() index_html= root.index_html
This is quite neat. What I did up to now was to get the Zope App through the product context with: app = context._ProductContext__app index_html = app.index_html I jumped into the python debugger on product initialization and inspected the context variable and was amazed to see what I could get my hands on (and what I could probably break), but your way is more verbose, I like it. Roché
participants (3)
-
Chris Withers -
Dieter Maurer -
Roché Compaan