I'm fiddling with SQLObject from CVS now, and I don't seem to be
understanding the documentation about foreignKey. The manual says:
"""
foreignKey:
You can give a class name (as a string) for foreignKey, which means
that the column references another class (which is another row in
another table). The column name should end with ID, and the database
column is expected to end with _id. This will create another method in
your class.
For instance, if the personID column points to the Person class,
then in addition to a personID attribute your class will have a person
attribute which will return the corresponding Person instance.
"""
Base on this, I would expect:
class ComponentCategory(SQLObject):
_columns = [
StringCol("name", length=100),
StringCol("description", default=None),
IntCol("sequenceNum", default=None)]
class Component(SQLObject):
_columns = [
StringCol("name"),
StringCol("categoryId", foreignKey="ComponentCategory",
default=None),
IntCol("sequenceNum", default=None)]
To behave as follows:
Instantiating:
c = Component.new(name="test")
And c should have an attribute "componentCategory" that returns either
None, or an instance of class ComponentCategory.
In fact, c does not have an attribute called "componentCategory". Am I
not understanding something?
...Edmund.
|