You can't as it doesn't have a parent.  It's a RelatedJoin and
therefore a many-to-many relationship.  If you want a parent-child
relationship you need a one-to-many relationship (one parent to many
children), and for that you need a MultipleJoin.

It's discussed in this thread:

http://groups.google.co.uk/group/turbogears/browse_frm/thread/347462c74e37dd94/df9301771d178b25

but essentially you just change the column type and get rid of
otherColumn parameter.

Ed

On 6/26/06, nEO  (a.k.a. gentoo.cn) <[EMAIL PROTECTED]> wrote:
>
> On 6/25/06, Jorge Vargas <[EMAIL PROTECTED]> wrote:
> > the first one is a common problem with SQLObject and Many-to-Many
> > relationships
>
> > http://trac.turbogears.org/turbogears/wiki/JoinaTableWithItself
>
> I have a question:
> How can I get the Region's parent Region?
>
> class Region(SQLObject):
>     name =  StringCol(alternateID=True)
>     borders = 
> RelatedJoin("Region",joinColumn='borders_id',otherColumn='parent_id')
>     parent_region =
> RelatedJoin("Region",joinColumn='parent_id',otherColumn='borders_id')
>
> SO will create table as,
>
> CREATE TABLE region_region (
> parent_id INT NOT NULL,
> borders_id INT NOT NULL
> );
>
> Then region1.borders will get region1's parent region
> region1.parent_region will get region1's borders
>
>
> class Region(SQLObject):
>     name =  StringCol(alternateID=True)
>     parent_region =
> RelatedJoin("Region",joinColumn='borders_id',otherColumn='parent_id')
>     borders = 
> RelatedJoin("Region",joinColumn='parent_id',otherColumn='borders_id')
>
> SO will create table as;
>
> CREATE TABLE region_region (
> borders_id INT NOT NULL,
> parent_id INT NOT NULL
> );
>
> Then region1.borders stilll get region1's parent region
> region1.parent_region stilll get region1's borders
>
> I'm confused, how can I get the region's parents region?
>
>
> --
> I'm the one, powered by nEO
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to