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:

gc= <TransientObjectContainer at GarbageCollector>
No GarbageCollector

Which is really strange because 'gc' was just reported to be a TOC!

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'

I get the expected response:

gc= <TransientObjectContainer at GarbageCollector>
GarbageCollector exists


I think I am misunderstanding something basic about python/zope here. Why does a TOC object evaluate to false?

Thanks,

Jonathan

_______________________________________________
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