On Jul 30, 2007, at 6:48 PM, Jonathon Anderson wrote:
> > I realize that it is probably much too late in the game for this, > but... > > I've always thought that returning None for get/get_by when no record > exists is less explicit than raising an exception. I really like > Django's idiom of having an Entity.DoesNotExist exception, such that I > could: > > try: > instance = Entity.get(instance_id) > except Entity.DoesNotExist: > print "no record of an instance with id %s" % instance_id > else: > print instance > > With sqlalchemy, I find myself always spelling: > > instance = Entity.get(instance_id) > if not instance: > print "no record of an instance with id %s" % instance_id > else: > print instance > > What do you think? we have this. you call query.<whatever>.one(), *or* you can call query.load(id) which also throws an exception. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---