Oleg Broytmann wrote:
On Thu, May 18, 2006 at 10:45:11PM +0400, Oleg Broytmann wrote:
Oh, BTW - list() calls __nonzero__(), so list(.select()) results in two
queries, and this is exactly the point to have neither __nonzero__() nor
__len__().
Ah, no - list() only calls __len__(). So I think it's possible to add
__nonzero__().
FWIW, I think list() no longer calls __len__() (it calls __size__() or
something), but only in some Python versions. I guess it was considered
a bug (for good reason).
I'm still not sure if it's a good idea to implement __len__() (maybe
conditional on the Python version, which is also icky). Implementing
__nonzero__ is probably for the best, since if it is always true that
leads to buggy code no one notices. And I if it raises an exception it
is incredibly annoying (cgi.FieldStorage raises an exception, and I hate
it).
One design decision for SO2 is if .select() should be iterable at all,
or if it should require .execute() or something to be called on it.
(For backward compatibility at least you'd be able to iterate with a
warning.) I think in some ways it confuses things, since .select()
represents a query that could be run, not an actual database operation.
Also there's the issue with lazy instantiation of objects, which
doesn't really work very well, and so now a list is created, but you
only get access to the iterator of the list. Though I suppose it would
be safe to load the result rows and instantiate the SQLObject instances
lazily; it's just keeping the cursor open that causes problems.
--
Ian Bicking / [EMAIL PROTECTED] / http://blog.ianbicking.org
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss