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
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to