[ZODB-Dev] ZODB class instances not behaving Pythonically

Patrick K. O'Brien pobrien@orbtech.com
Mon, 8 Oct 2001 12:40:57 -0500


I just realized that PersistentMapping and IOBTree are behaving just like
dictionaries, which is perfectly Pythonic. And since they are initially
empty, their truth value is zero/false, just like empty dictionaries. Sorry
to cause a fuss. I was momentarily confused. (Picture Jiminy Glick when you
read "confused.")

---
Patrick K. O'Brien
Orbtech (http://www.orbtech.com)
"I am, therefore I think."

-----Original Message-----
From: zodb-dev-admin@zope.org [mailto:zodb-dev-admin@zope.org]On Behalf Of
Patrick K. O'Brien
Sent: Monday, October 08, 2001 9:45 AM
To: ZODB
Subject: [ZODB-Dev] ZODB class instances not behaving Pythonically

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."



_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://lists.zope.org/mailman/listinfo/zodb-dev