[ZODB-Dev] ZODB class instances not behaving Pythonically
Patrick K. O'Brien
pobrien@orbtech.com
Mon, 8 Oct 2001 09:44:51 -0500
Can someone explain the difference in behavior exhibited by ZODB classes,
such as PersistentMapping, versus a regular Python class instance, as shown
in this PyCrust shell session? Actually, FolderManager is a Persistent
class, so that ZODB class appears to be fine. But PersistentMapping, IOBTree
and others don't behave as expected:
>>> from ZODB.PersistentMapping import PersistentMapping
>>> pm = PersistentMapping()
>>> pm
<PersistentMapping instance at 01A39F90>
>>> if pm: print "yeah"
...
>>> if pm is not None: print "yeah"
...
yeah
>>> not pm
1
>>> not not pm
0
>>>
>>> from ZODBrowser.folder import FolderManager
>>> fm = FolderManager()
>>> fm
<FolderManager instance at 01B610C0>
>>> if fm: print "yeah"
...
yeah
>>> if fm is not None: print "yeah"
...
yeah
>>> not fm
0
>>> not not fm
1
>>>
---
Patrick K. O'Brien
Orbtech (http://www.orbtech.com)
"I am, therefore I think."