|
From: Mike E. <mi...@mi...> - 2003-11-27 05:57:27
|
Can anyone tell me why I get the following error? I am creating a new =
object, and then trying to access that object via a newly queried second =
object. And getting a list index out of range error. If I simply iterate =
through the new list (without referring to the item by index) then it =
will appear in the list. If I run a different script with the same code =
querying the table I can access it okay.
from SQLObject import *
class Person(SQLObject):
_connection =3D MySQLConnection(host=3D'localhost', db=3D'jcpos',
user=3D'test', passwd=3D'')
first_name =3D StringCol(length=3D100,default=3D"")
middle_initial =3D StringCol(length=3D1, default=3D"")
last_name =3D StringCol(length=3D100, default=3D"")
newperson =3D Person.new(first_name=3D"Mike")
newid =3D newperson.id
listofpersons =3D Person.select()
print listofpersons[newid].first_name
Traceback (most recent call last):
File "D:\dev\pythontest\sqlerror.py", line 18, in ?
print listofpersons[newid].first_name
File "C:\Python23\Lib\site-packages\SQLObject\SQLObject.py", line =
1056, in __g
etitem__
return list(self.clone(start=3Dvalue, stop=3Dvalue+1))[0]
IndexError: list index out of range |