[Zope-dev] The Application object
Chris McDonough
chrism@digicool.com
Mon, 17 Jul 2000 13:17:20 -0400
So it's kosher then to reimport the Zope module and use app() in a
constructor method, Shane? I was always afraid it would do something
horrible.
> -----Original Message-----
> From: Jeff K. Hoffman [mailto:jeff.hoffman@goingv.com]
> Sent: Monday, July 17, 2000 1:11 PM
> To: Shane Hathaway
> Cc: Chris McDonough; 'Jeff K. Hoffman'; zope-dev@zope.org
> Subject: Re: [Zope-dev] The Application object
>
>
> On Mon, 17 Jul 2000, Shane Hathaway wrote:
>
> > The way to get the root application object is to open a
> connection to
> > the ZODB and get the 'Application' object from the list of root
> > objects. There is an easy shortcut:
> >
> > import Zope
> > app = Zope.app()
> >
> > app now refers to a *copy* of the root Application object.
>
> Yeehaw, that worked! I was so close. :-)
>
> > When you're done modifying it and its descendants you have
> to commit or
> > abort the transaction.
>
> [snip]
>
> Do I need to commit or abort even if I don't make changes to the
> application object? The only thing I need it for is to get to the
> Control_Panel; I am instantiating ZClass instances in the
> constructor of a
> Python class, i.e.:
>
> class MyClass:
>
> def __init__(self, id, title=''):
> import Zope
> app = Zope.app()
>
> ob = app.Control_Panel.Products.MyProduct.MyZClass('newId')
> ob.id = 'newId'
>
> self._setObject('newId', ob)
>
> # Do I need a get_transaction().abort() here? Will that
> not abort
> # the wrong transaction?
>
> app._p_jar.close()
>
> ...
>
> > This gives you all kinds of benefits like undo and elimination of
> > threading conflicts.
>
> [snip]
>
> Good stuff. Thanks, Shane.
>
> > Shane
>
> --Jeff
>
> ---
> Jeff K. Hoffman 704.849.0731 x108
> Chief Technology Officer
mailto:jeff.hoffman@goingv.com
Going Virtual, L.L.C. http://www.goingv.com/