On Thu, Feb 07, 2008 at 03:03:05PM -0600, Christopher Singley wrote:
> On Thursday 07 February 2008 14:32:09 Oleg Broytmann wrote:
> > I very much hope you understand that .count() does a separate query which
> > could be very expensive, and you call .count() two times!
> 
> Thank you very much for the suggestion; it's easy to change to 
> len(list(selectResults)).

   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:
   ...

> Any ideas for how to improve the class definition syntax for my DynamicState/ 
> DynamicSQLObject?  To see the problem, below are some subclasses showing how 
> they're used.  I'm trying to represent the US federal employers' tax.  These 
> rules change every year, so they are well represented by DynamicState/ 
> DynamicSQLObject.
> 
> As you can see, it's pretty unfortunate to keep cutting&pasting all those 
> parent/stateClass/states attributes.  If anybody's got any ideas for how to 
> make this syntax tighter, I'd be very much obliged.

   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.

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            [EMAIL PROTECTED]
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
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