[ZODB-Dev] Typechecking oid in getitem

Christian Reis kiko at async.com.br
Mon May 19 15:32:08 EDT 2003


On Mon, May 19, 2003 at 05:53:35PM +0100, Toby Dickenson wrote:
> > I can make POSKeyError more beautiful ;) later.
> 
> POSKeyError displays repr(oid), and I cant think of anything better in the 
> general case. Jeremys Long oids will make this nicer.

Well, in CVS HEAD I have:

        def _fmt_oid(oid):
            if oid: 
                return "%016x" % ZODB.utils.u64(oid)
            return oid

    class POSKeyError(KeyError, POSError):
        def __str__(self):
            return _fmt_oid(self.args[0])

So it sort of assumes the oid is in the correct format (try running that
with an oid of 1 (IntType) to see what I mean). We could check for the
type there and print out something nicer.

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



More information about the ZODB-Dev mailing list