On 26/07/05, Berthold Höllmann <berthold@despammed.com> wrote:
> But each "Project" also has "Workpackage"s that have
> "Subproject"s. The "Workpackage"s and "Subproject"s have leader and
> deputy leaders that are "Person"s also. So where are the RelatedJoins in
> "Person" pointing to? To "Project", "Workpackage", or "Subproject"?

Wherever you tell them to point. e.g. RelatedJoin('Project') points to Project relying on there being a RelatedJoin('Person') in Project for symmetry.
Oh, you probably want to specify a joinColumn
If there is more than one column linking that table to this you can choose which you want to join to by adding joinColumn='Column' as an argument to the join. e.g. see below. You don't need joinColumn if there is no ambiguity.
I think I am right about these, I haven't actually had occasion to use one.

> The "Leader" in one "Workpackage" could be "Leader" for a "Subproject"
> also or "DeputyLeader" for another "Worpackage", or "Subproject". So
> it seems to me there is no easy way to model this depenedencies using
> SQLObject?

Sounds like a challenge! :-)
I hadn't mentioned joinColumn before.
These are only partial - I haven't put in all the relationships you would need, but hopefully there are enough to show how it is done.
How about...?

class Project(SQLObject):
    leader = ForeignKey('Person')
    deputyLeader = ForeignKey('Person')
    workers = RelatedJoin('Person')
class Workpackage(SQLobject):
    parentProject = ForeignKey('Project')
    subProjects = MultipleJoin('Subproject')
    ...
class Subproject(SQLObject):
    parentWorkpackage = ForeignKey('Workpackage')
    leader = ForeignKey('Person')
    ...
class Person(SQLObject):
    leadsProjects = MultipleJoin('Project', joinColumn='leader')
    deputyLeadsProjects = MultipleJoin('Project', joinColumn='deputyLeader')
    leadsSubprojects = MultipleJoin('Subproject')
    worksForProjects = RelatedJoin('Project')
    ...

hopefully should be enough to see what is going on.
Here the related joins between Person and Project do not need to be told their joinColumn, because they can only link to each other.
Or how about...?

class Project(SQLObject):
    leader = ForeignKey('Person')
    deputyLeader = ForeignKey('Person')
    childProjects = MultipleJoin('Projects')
    parentProject = ForeignKey('Projects')
class Person(SQLObject):
    leadsProjects = MultipleJoin('Project', joinColumn='leader')
    deputyForProjects = MultipleJoin('Project', joinColumn='deputyLeader')

Here, I have assumed that workpackages are actually much like projects, (probably not a valid assumption, but for an example), so I did a couple of joins to self in Project for the subproject relationships. The only disadvantage is that in SQLObject there is no possibility of assigning Null value for the parentProject foreign key. One workaround: you could make it point to itself if there is no parent and then deal with itself turning up among its childProjects. A bit ugly in this case.

Again, I hope this helps.

God bless,
John