Zope 2.7.2, restrictedTraverse or hasattr
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 kai.hoppert@tomcom.de | 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
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
Why dont you try: 'myobject' in Object3.objectIds('meta_type_name') HTH, Suresh "Kai Hoppert" <kai.hoppert@tomcom.de> wrote in message news:A54D5004067F2442B1B8177EB6FC41DD337E4F@justus.schrottplatz... 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 kai.hoppert@tomcom.de | 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 - Zope-Dev@zope.org 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 )
participants (3)
-
Dieter Maurer -
Kai Hoppert -
sureshvv