From: Christopher S. <csi...@gm...> - 2008-02-07 21:51:50
|
On Thursday 07 February 2008 15:26:17 Oleg Broytmann wrote: > Again, you better cache the list as you need the item from the list: > > result = list(selectResults) > if result: > if len(result) == 1: > return result[0] > else: > ... > else: > ... Yes, I did cache the list; my revised code is this: === selectResults = list(selectResults) if selectResults: try: assert len(selectResults)==1 except AssertionError: ... object = selectResults[0] else: object = None return object === > These pairs could be generated in a loop, but I doubt it'd be any > simpler because then you will need to manipulate SQLObject's class registry > which is usually handled automagically. All right then, I guess that's a reasonable effort to make it "as simple as possible, but not simpler" (to quote Einstein). Is there any sort of repository anywhere for SQLObject subclasses and extensions, like the Python Cheese Shop? I feel like I am reinventing the wheel with some of these classes. Anyway, thanks for your help. SQLObject is a pleasure to work with. cs |