|
From: Ian B. <ia...@co...> - 2003-11-04 02:23:36
|
On Nov 3, 2003, at 1:01 PM, Frank Barknecht wrote:
>> As a result I actually got rid of __len__ at some point (hmm... maybe
>> between 0.4 and 0.5, though if so I forgot to document it), and
>> replaced it with a .count() method so database calls wouldn't be
>> implicitly triggered. Sadly this ruins truth-testing, though maybe
>> that was dangerous too.
>>
>> Anyway, this shouldn't happen in 0.5.
>
> Hm, I'm using current CVS, and there SQLObject.py still has a __len__,
> but no "count" method. I actually don't use a pure list in my code
> but a class called "ProductDisplay" derived from list. With some
> little changes I could make without inheriting from list: I only use
> "for x in productDisplay_instance: do things" which should be possible
> without ProductDisplay being a list. Would going this route help?
You're right, I didn't remove __len__. But I fully intended to ;)
Yes, if you just iterate over SelectResults it should work fine. Even
if you just use:
def makelist(v):
result = []
for val in v: result.append(val)
return result
That should save you from excessive counts.
I plan to release 0.5.1 soon, to fix a couple little bugs. I'll
probably add .count() in there too.
--
Ian Bicking | ia...@co... | http://blog.ianbicking.org
|