Re: [Zope] Avoiding acquisition aka testing for contained objects

2000-11-16 Thread Dieter Maurer

Stefan H. Holek writes:
 > If I want to know whether a certain object is contained in 
 > the current folder I do this:
 > 
 > 
 >   yes it's here
 > 
 >   not here
 > 
 > 
 > Id like to know whether this is the best/most efficient way to do it.
 > Things like hasattr() are subject to aquisition i.e. they would find
 > an index_html method along the acquisition path...
There is a trick:

  

avoids (implicit) acquisition.

How it works:

"aq_explicit" returns the explicit acquisition wrapper
for "this". This wrapper does not acquire automatically
but must be told explicitly. As "hasattr" does not to
that, it tests for an attribute of "this()" and
not an acquired attribute.


Dieter

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Avoiding acquisition aka testing for contained objects

2000-11-16 Thread Stefan H. Holek

On Wed, 15 Nov 2000, Johan Carlsson wrote:

> > If I want to know whether a certain object is contained in 
> > the current folder I do this:
> > 
> > 
> >   yes it's here
> > 
> >   not here
> > 

> hasattr(self.aq_base, 'index_html') should probably work.
> 
> aq_base returns the unwrapped base object.

Thanks, but it seems that aq_base is not available from DTML 

- Hmm

Regards,
Stefan


___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Avoiding acquisition aka testing for contained objects

2000-11-15 Thread Johan Carlsson



> If I want to know whether a certain object is contained in 
> the current folder I do this:
> 
> 
>   yes it's here
> 
>   not here
> 
> 
> Id like to know whether this is the best/most efficient way to do it.
> Things like hasattr() are subject to aquisition i.e. they would find
> an index_html method along the acquisition path; something I do not 
> want. I also cannot bracket everything in a  because
> chopping my namespace is not what I want either.
> 

Stefan,

hasattr(self.aq_base, 'index_html') should probably work.

aq_base returns the unwrapped base object.

There is other aq_wrapper methods as well:
aq_parent (returns the parent wrapper) and aq_self.
I don't really know (of the top of my brain) the differens
between aq_base and aq_self. 
There is however a wiki some where in the Interface section
on Zope.org that tells you more, no link pops in to my mind 
at the moment so you just have to search for it.

I think hasattr() is a better way to look upp attributes but
that's just my 5 cents.

Regards,
Johan Carlsson







___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )