[PEAK] QueryDM's with no query params

Phillip J. Eby pje at telecommunity.com
Fri May 20 23:05:14 EDT 2005


At 10:52 PM 5/20/2005 -0400, Erik Rose wrote:
>I still wonder why it was iterating forever. Maybe that belies a deeper 
>bug someplace; I may take a look when schedule permits.

That's because the way Python iterates over objects with a __getitem__ is 
that it starts at 0 and increases the index by 1 until the object raises an 
IndexError.  So, if your DM ignores the oid, then it'll never get an error, 
but just keep returning objects, and Python will never stop iterating.

In any event, I've fixed this now by making all DM's have an __iter__ that 
raises NotImplementedError unless you override it.  See my other post on 
this topic.  Also, I've just checked in an update to the "bulletins" 
example that refactors some common code in the DM's to make a super-trivial 
"SQL DM" base class.  It's likely not a competitor for your and Ulrich's 
SQL DM work, but it should give you some idea of how to implement some of 
the new features like __iter__, get, _check, etc.




More information about the PEAK mailing list