[ZODB-Dev] Typechecking oid in getitem
Toby Dickenson
tdickenson at geminidataloggers.com
Mon May 19 18:53:35 EDT 2003
On Monday 19 May 2003 5:41 pm, Christian Reis wrote:
> On Mon, May 19, 2003 at 01:16:26PM -0300, Christian Reis wrote:
> > Note that many places we already do try: except KeyError, so maybe it
> > would be a matter of changing KeyError to (KeyError, TypeError) in these
> > places?
>
> How does this look?
POSKeyError implies "object not found under that oid", not "malformatted oid".
What about something like
try:
pos=_index[oid]
except KeyError:
raise POSKeyError(oid)
+ except TypeError:
+ raise TypeError('malformatted oid %r' % (oid,))
> 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.
--
Toby Dickenson
http://www.geminidataloggers.com/people/tdickenson
More information about the ZODB-Dev
mailing list