[Zope] A quick zope/python question
Andreas Jung
lists at zopyx.com
Tue May 9 11:30:02 EDT 2006
--On 9. Mai 2006 11:18:25 -0400 Jonathan <dev101 at magma.ca> 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: info at zopyx.com - Phone +49 - 7071 - 793376
E-Publishing, Python, Zope & Plone development, Consulting
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope/attachments/20060509/bb43023a/attachment.bin
More information about the Zope
mailing list