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:[EMAIL PROTECTED]]
> Sent: Monday, July 17, 2000 1:11 PM
> To: Shane Hathaway
> Cc: Chris McDonough; 'Jeff K. Hoffman'; [EMAIL PROTECTED]
> 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:[EMAIL PROTECTED]
Going Virtual, L.L.C.                         http://www.goingv.com/

_______________________________________________
Zope-Dev maillist  -  [EMAIL PROTECTED]
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 )

Reply via email to