Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1169 (closed defect: fixed)

Opened 11 years ago

Last modified 10 years ago

SingleJoin, MultipleJoin not working.

Reported by: miya Owned by: jorge.vargas
Priority: normal Milestone:
Component: Toolbox.Catwalk Version: 1.0b1
Severity: normal Keywords:
Cc:

Description (last modified by jorge.vargas) (diff)

I really dont know why this is happening.

Please read this post in the TG's group.

 http://groups-beta.google.com/group/turbogears/browse_thread/thread/ef9685c58eb41bbd/1a5f9dadfb4e6b84#1a5f9dadfb4e6b84

raise AttributeError("%s instance has no attribute '%s'" %
(self.soClass.__name__, attr))
AttributeError: Pet instance has no attribute 'tgID'
Request Headers:
  COOKIE: tg-visit=07ad5cd8a247b08a9df1a3d2acdcebd944aaa657

The model.py
//
------------------------------------------------------------------------------------

class Pet(SQLObject):
    class sqlmeta:
        table = 'tg_pet'
        name = UnicodeCol(length = 40)
        surname = UnicodeCol(length = 40)
        color = UnicodeCol(length = 40)
        userid = ForeignKey("User")

class User(SQLObject):
    """
    Reasonably basic User definition. Probably would want additional
attributes.
    """
    # names like "Group", "Order" and "User" are reserved words in SQL
    # so we set the name to something safe for SQL
    class sqlmeta:
        table = "tg_user"

    user_name = UnicodeCol(length=16, alternateID=True,                alternateMethodName="by_user_name")
    email_address = UnicodeCol(length=255, alternateID=True,
                               alternateMethodName="by_email_address")
    display_name = UnicodeCol(length=255)
    password = UnicodeCol(length=40)
    created = DateTimeCol(default=datetime.now)

    myPet = SingleJoin("Pet")

    # groups this user belongs to
    groups = RelatedJoin("Group", intermediateTable="user_group",
                         joinColumn="user_id", otherColumn="group_id")

And I tried to use MultipleJoin? and it doesn't work either.

The project is very simple that i'm using is really simple.

I just did

tg-admin quickstart -i -t tgbig

and then created the Pet class and modified the User class to have a singleJoin. (only that)

I'm using Kubuntu Dapper if that helps.

Change History

comment:1 Changed 11 years ago by miya

OK. This is crazy but I think that the bug is that when you create your project with the "-t tgbig" option, SingleJoin? and MultipleJoin? (and RelatedJoin?) doesn't work.

So, creating the project without it, solves my problem. (but not the problem per se)

comment:2 Changed 11 years ago by miya

Ooooops, I totally forgot to include the SingleJoin? attribute in User. So everything stays the same... :(

comment:3 Changed 11 years ago by jorge.vargas

  • Owner changed from anonymous to jorge.vargas
  • Description modified (diff)

comment:4 Changed 11 years ago by hads

This is similar to #701

comment:5 Changed 11 years ago by miya

  • Status changed from new to closed
  • Resolution set to fixed

Ok. I think I solved the problem.

The thing is that the User's table name is 'tg_user', and whenever you do a MultipleJoin? or SingleJoin? you have to explicity specify which is the name of the joinColumn, which must be user_id.

myPet = SingleJoin?("Pet", joinColumn = "user_id")

I think that joinColumn defaults to the name of the table + '_id' or sth like that.

Sooo... watch it when you change the table property of the sqlmeta class

cya!

Note: See TracTickets for help on using tickets.