I expect it to be iterable because most Python objects are iterable.  :)  It makes using them easy.

I guess there are a few things it could return if it was iterable:

1)  It could return a a column name.  This would be useful if sqlobject also allowed you to use subscript notation to get a value.  Essentially this would simulate a dictionary without having to do an asDict. 

2)  It could return an array or tuple of two or three elements.  If  two elements, return column name and value.  Or if you decide type is important return three elements:  column name, type, and value.

Thanks for the suggestions of columnList and asDict.  Neither of these suggestions appear in the documentation!  :)  (columnList is mentioned---but in a different context).   As I'm not using magic attributes I'll use asDict.


On Thu, Feb 28, 2008 at 5:32 AM, Oleg Broytmann <phd@phd.pp.ru> wrote:
On Thu, Feb 28, 2008 at 02:57:50AM -0200, Sam's Lists wrote:
> I can print the record find by coercing it into a string.
> But I'd like to be able to iterate through it myself.  And I can't.  I keep
> getting:  'TypeError: 'TheRun' object is not iterable'
> Why is this the case?

  Why do you expect a record to be iterable? There is a list of column
names, but there is no a list of values, you have to get a value for
a column by the column's name.
  I don't see any meaning in the code

for value in my_row:...

  because during the loop you don't know column name and type for the
  You can iterate through the list of columns:

for column in row.sqlmeta.columnList:
  print getattr(row, column.name)

but remember there is also a list of joins (sqlmeta.joins) and indices.

    Oleg Broytmann            http://phd.pp.ru/            phd@phd.pp.ru
          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.
sqlobject-discuss mailing list