I can't figure out the opposite angle on this. In __init__.py, my product creates a root-level object named 'S' with Martijn's method below. Now another module 'D' needs to look up 'S' and get a reference to the object so it can call one of its methods "S.next". But I don't see how to look up 'S'. I'm sure I'm just being dense. Can somebody help? -- Loren
From: Robert Sander [mailto:zope-dev@beteigeuze.cs.tu-berlin.de]
On Thu, Feb 10, 2000 at 03:40:38PM -0000, Phil Harris wrote:
I think there's something called app?
It's declared in <zopedir>/lib/python/Main.py.
That may be what your looking for??
I don't know, the object app is not in the global namespace when __init__.py of my Product is called.
From: Martijn Pieters <mj@digicool.com>
Here's what I'd do (in __init__.py):
def initialize(context): app = context._ProductContext__app # Don't you love private name mangling if not hasattr(app, #IdForObject#): object = Object() app._setObject(#IdForObject#, object) get_transaction().note('Added Object') get_transaction().commit()
context._ProductContext__app is the root object. #IdForObject# is a string ID for the object.
-- Martijn Pieters, Software Engineer | Digital Creations http://www.digicool.com | Creators of Zope http://www.zope.org | mailto:mj@digicool.com ICQ: 4532236 | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 -------------------------------------------
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )