Hello,
I have a couple classes with ForeignKey references and am having difficulty getting SQLObject to connect the tables. I can create instances of these classes, but when I print out instances of the class, I see that item displayed with a u'stringHere', even though I *have* created the corresponding instance in the other table. When I try to access that class attribute directly I get the following error:
Traceback (most recent call last):
File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\etc\bar.py", line 60, in ?
print str(i.lexeme)
File "<string>", line 1, in <lambda>
File "<string>", line 1, in <lambda>
File "c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\main.py", line 1159, in _SO_foreignKey
return joinClass.get(id, connection=self._connection)
File "c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\inheritance\__init__.py", line 161, in get
val = super(InheritableSQLObject, cls).get(id, connection, selectResults)
File "c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\main.py", line 894, in get
id = cls.sqlmeta.idType(id)
ValueError: invalid literal for int(): (eat)
Obviously, for some reason the SQLObject is not connecting the keys for the tables together. What can I do to solve this problem?
Here are the class definitions, if they help at all:
<Spanish 2 name='como' partOfSpeech='V' lexemeID=u'(eat)' otherAttributes=[]>
**the lexemeID is not a number...?
class foo(InheritableSQLObject):
name = StringCol()
partOfSpeech = StringCol()
concept = ForeignKey('Concept')
modifiers = PickleCol(default=[])
grammarExceptions = PickleCol(default=[])
otherAttributes = PickleCol(default=[])
class SpanishLexeme(Lexeme):
"""The class that represents all words in the Spanish Lexeme."""
class Lexicon(InheritableSQLObject):
name = StringCol()
partOfSpeech = StringCol()
lexeme = ForeignKey('Lexeme')
otherAttributes = PickleCol(default=[])
class Spanish(Lexicon):
lexeme = ForeignKey('SpanishLexeme')
...I omitted the concept class, but am having the same problem. However, the Concept class is able to recognize references to itself.
Your help is very much appreciated,
Emily
I have a couple classes with ForeignKey references and am having difficulty getting SQLObject to connect the tables. I can create instances of these classes, but when I print out instances of the class, I see that item displayed with a u'stringHere', even though I *have* created the corresponding instance in the other table. When I try to access that class attribute directly I get the following error:
Traceback (most recent call last):
File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\etc\bar.py", line 60, in ?
print str(i.lexeme)
File "<string>", line 1, in <lambda>
File "<string>", line 1, in <lambda>
File "c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\main.py", line 1159, in _SO_foreignKey
return joinClass.get(id, connection=self._connection)
File "c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\inheritance\__init__.py", line 161, in get
val = super(InheritableSQLObject, cls).get(id, connection, selectResults)
File "c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\main.py", line 894, in get
id = cls.sqlmeta.idType(id)
ValueError: invalid literal for int(): (eat)
Obviously, for some reason the SQLObject is not connecting the keys for the tables together. What can I do to solve this problem?
Here are the class definitions, if they help at all:
<Spanish 2 name='como' partOfSpeech='V' lexemeID=u'(eat)' otherAttributes=[]>
**the lexemeID is not a number...?
class foo(InheritableSQLObject):
name = StringCol()
partOfSpeech = StringCol()
concept = ForeignKey('Concept')
modifiers = PickleCol(default=[])
grammarExceptions = PickleCol(default=[])
otherAttributes = PickleCol(default=[])
class SpanishLexeme(Lexeme):
"""The class that represents all words in the Spanish Lexeme."""
class Lexicon(InheritableSQLObject):
name = StringCol()
partOfSpeech = StringCol()
lexeme = ForeignKey('Lexeme')
otherAttributes = PickleCol(default=[])
class Spanish(Lexicon):
lexeme = ForeignKey('SpanishLexeme')
...I omitted the concept class, but am having the same problem. However, the Concept class is able to recognize references to itself.
Your help is very much appreciated,
Emily
------------------------------------------------------------------------- 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
