Oleg Broytmann wrote:
You have to understand that SQLObject creates a hidden intermediate
table that stores cross-pointers for an every pair of RelatedJoins. If you
want to create more than one RelatedJoin you have to give the name for the
tables yourself. Try this:
class Person(SQLObject):
name = StringCol()
clientProjects = RelatedJoin("Project",
intermediateTable="person_project_clients")
contractorProjects = RelatedJoin("Project",
intermediateTable="person_project_contractors")
class Project(SQLObject):
name = StringCol()
clients = RelatedJoin("Person", intermediateTable="person_project_clients")
contractors = RelatedJoin("Person",
intermediateTable="person_project_contractors")
Thank you for your help. The above created the following tables:
person
person_project_clients
person_project_contractors
project
And after running Project.get(1).addPerson(Person.get(2)),
person_project_clients contains person_id=2, project_id=1
person_project_contractors is empty
After running Project.get(1).addPerson(Person.get(1)),
person_project_clients contains person_id=2, project_id=1; person_id=1,
project_id=1
person_project_contractors is empty
Then I try:
>>> Project.get(1).addContractor(Person.get(1))
Traceback (most recent call last):
File "<console>", line 1, in ?
AttributeError: 'Project' object has no attribute 'addContractor'
What is the right way to specify that I'm adding a contractor and not a
client?
Tim
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss