Ignore:
Timestamp:
27 May 2009, 09:32:41 (15 years ago)
Author:
uli
Message:

Make receiverid more robust.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-rewrite/src/waeup/datacenter.py

    r4183 r4184  
    144144        memory only and will vanish as soon as the request is over. In
    145145        this case we can use the memory address of it.
     146
     147        Both, the id() result and the ZODB oid, are actually integers
     148        which we return as strings. To make the difference chrystal
     149        clear, we prepend ``z`` to ids taken from ZODB oids.
    146150        """
    147151        if not hasattr(obj, '_p_oid'):
    148152            return str(id(obj))
    149153        oid = getattr(obj, '_p_oid')
    150         return str(struct.unpack('>Q', oid)[0])
     154        if oid is None:
     155            # The persistent object is not stored in the ZODB
     156            return str(id(obj))
     157        return 'z%s' % struct.unpack('>Q', oid)[0]
    151158
    152159       
Note: See TracChangeset for help on using the changeset viewer.