[ZODB-Dev] Persistent unhashable?

Christian Robottom Reis kiko@async.com.br
Wed, 4 Jul 2001 21:27:54 -0300 (BRT)


On Tue, 3 Jul 2001, John D. Heintz wrote:

> Now comes the wisdom I learned: In order to get a _p_oid for just created
> objects you can make sure that they are refered to by an already persisted
> object and then get_transaction().commit(1) to commit a sub-transaction.
> This will have the side effect of generating persistent ids for all objects
> reachable from the root.

Does this mean I'll need to add this object to a catalog temporarily so it
gets an oid? Ugh! That's rather awful.

> PS - Our persistent base class uses a __hash__ function like this to make the
> process more convenient:
> def __hash__(self):
> 	if not self._p_oid:
> 		some.global.ensurePid(self)
> 	return hash(self._p_oid)

I could also raise an unhashable error, I suppose. Is self._p_oid set to 0
or None when the object has none, or is it just missing from the __dict__?

Take care,
--
/\/\ Christian Reis, Senior Engineer, Async Open Source, Brazil
~\/~ http://async.com.br/~kiko/ | [+55 16] 274 4311