[Zope] restrictedTraverse without acquisition

Jonathan Hobbs toolkit at magma.ca
Wed Jul 14 07:27:08 EDT 2004


----- Original Message ----- 
From: "Paul Winkler" <pw_lists at slinkp.com>
To: <zope at zope.org>
Sent: July 13, 2004 6:04 PM
Subject: Re: [Zope] restrictedTraverse without acquisition


> On Tue, Jul 13, 2004 at 03:56:51PM -0400, Jonathan Hobbs wrote:
> > > On Tue, Jul 13, 2004 at 10:50:59AM -0700, R Karthick wrote:
> > > > 
> > > > hi!!
> > > > 
> > > > thank you for you reply.
> > > > 
> > > > Yeah it seems to be a good solution. but can't i just
> > > > switch off acquisition in restrictedTraverse, when i
> > > > need to?
> > > 
> > > restrictedTraverse has no such feature.
> > > 
> > > You could also item access rather than attribute access.
> > > This does not use acquisition. e.g.:
> > > 
> > > try:
> > >     context.wg['projects']['abc']
> > >     ...
> > 
> > If cycles are a concern,  instead of raising an error condition try:
> > 
> > foo = context.restrictedTraverse('/wg/projects')
> > if not hasattr(foo, 'abc'):
> >    ...
> 
> hasattr acquires.

Point conceded... :)


Jonathan




More information about the Zope mailing list