[Zope-dev] Zope 2.7.2, restrictedTraverse or hasattr

2004-08-02 Thread Kai Hoppert
Hi all,

i actually have a Problem with restrictedTraverse and hasattr.

Object1
Object2
Object3


I want to test if there exists a Object in Object3 wich has the same id and meta type 
how Object2 (id=myobject).
so i ask

Object3.restrictedTraverse('myobject',None) or

hasattr(Object3,'myobject')

i every time get's true back. I know that he jump's to Object2. i testet this with 
absolute_url, but this makes no sense i think. Either i never noticed that this both 
funktions works in this way or it is a bug. If it is no bug has anybody a solution for 
my problem?

Greetings

Kai Hoppert 
___
tomcom Gesellschaft für Informationstechnologie mbH
Heuriedweg 14 | D-88131 Lindau
Fon +49 (0)8382 975844 | Fax +49 (0)8382 975855
[EMAIL PROTECTED] | http://www.tomcom.de

This document should only be read by those persons to whom it is addressed and is not 
intended to be relied upon by any person without subsequent written confirmation of 
its contents.  tomcom disclaims all responsibility and accepts no liability for the 
consequences of any person acting, or refraining from acting on the contents of this 
document.  Any unauthorised form of dissemination, copying, disclosure, modification, 
distribution and/or publication of this message is strictly prohibited. For 
information about tomcom please contact us on +49.8382.975844 or visit our web site at 
www.tomcom.de


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


Re: [Zope-dev] Zope 2.7.2, restrictedTraverse or hasattr

2004-08-02 Thread Dieter Maurer
Kai Hoppert wrote at 2004-8-2 14:04 +0200:
i actually have a Problem with restrictedTraverse and hasattr.

Object1
   Object2
   Object3
   

I want to test if there exists a Object in Object3 wich has the same id and meta type 
how Object2 (id=myobject).
so i ask

Object3.restrictedTraverse('myobject',None) or

hasattr(Object3,'myobject')
 
i every time get's true back.

You can write a Script(Python) hasattr_unacquired
with parameters obj, attr and body

 return hasattr(obj.aq_inner.aq_explicit, attr)

Note that a solution without the aq_inner will often work
but is not reliable...


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