On Fri, 2003-04-18 at 15:44, Luke Opperman wrote:
> Not sure if i just saw a message about this, but can't find it..
>
> modification to _SO_fetchAlternateID to deal with the situation where
> there is no record with that value.
>
> def _SO_fetchAlternateID(cls, dbIDName, value):
> result = cls._connection._SO_selectOneAlt(
> cls,
> [cls._idName] +
> [col.dbName for col in cls._columns],
> dbIDName,
> value)
> if not result:
> raise KeyError, "The object %s by the alternate ID (%s) %s
> does not exist" % (cls.__name__, dbIDName, value)
> obj = cls(result[0])
> ....
Sure, that seems right. I've named it SQLObjectNotFound, subclass
LookupError. At some point I'll get rid of the lazy fetching of column
data, at which point trying to instantiate a non-existant object will
raise the same exception.
Ian
|