--On 9. Mai 2006 11:18:25 -0400 Jonathan <[EMAIL PROTECTED]> wrote:

I have a short python script:

gc = context.restrictedTraverse('coup/temp_folder/GarbageCollector', None)
print 'gc=',str(gc)
if gc:
  print 'GarbageCollector exists'
else:
  print 'No GarbageCollector'

which, when run produces:

Check the implementation. "if obj" calls obj.__nonzero__() or obj.__len__().. depending on the implemenation this will explain the result



When the script is changed to:

gc = context.restrictedTraverse('coup/temp_folder/GarbageCollector', None)
print 'gc=',str(gc)
if gc is not None:
  print 'GarbageCollector exists'
else:
  print 'No GarbageCollector'

This is the right way to do it.

-aj

--
ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübingen - Germany
Web: www.zopyx.com - Email: [EMAIL PROTECTED] - Phone +49 - 7071 - 793376
E-Publishing, Python, Zope & Plone development, Consulting

Attachment: pgppDSSxP4hG6.pgp
Description: PGP signature

_______________________________________________
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to