All, I have been working through some TurboGears tutorial to learn more the framework. I have sucessfully worked through the Wiki20 tutorial, and have started this tutorial:
http://aymanh.com/turbogears-tutorial-social-bookmarking-application I have was able to succesfully create the database with the generated code, but when I add the reccomended code as described in the tutorial and get several errors : ================================================== Traceback (most recent call last): File "/usr/bin/tg-admin", line 7, in ? sys.exit( File "/usr/lib/python2.4/site-packages/TurboGears-1.0b1-py2.4.egg/turbogears/command/base.py", line 356, in main command.run() File "/usr/lib/python2.4/site-packages/TurboGears-1.0b1-py2.4.egg/turbogears/command/base.py", line 143, in run command.the_runner.run(sys.argv) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/manager/command.py", line 102, in run runner.run() File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/manager/command.py", line 233, in run self.command() File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/manager/command.py", line 575, in command soClass.createTable() File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/main.py", line 1332, in createTable conn.createTable(cls) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/dbconnection.py", line 528, in createTable self.query(self.createTableSQL(soClass)) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/dbconnection.py", line 307, in query return self._runWithConnection(self._query, s) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/dbconnection.py", line 221, in _runWithConnection val = meth(conn, *args) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/dbconnection.py", line 304, in _query self._executeRetry(conn, conn.cursor(), s) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/dbconnection.py", line 299, in _executeRetry return cursor.execute(query) psycopg.ProgrammingError: ERROR: relation "tg_user" does not exist CREATE TABLE bookmark ( id SERIAL PRIMARY KEY, user_id INT, CONSTRAINT user_id_exists FOREIGN KEY (user_id) REFERENCES tg_user (id) , link_id INT, CONSTRAINT link_id_exists FOREIGN KEY (link_id) REFERENCES link (id) , title VARCHAR(64) ) ===================================================================== Here is my code: ===================================================================== from datetime import datetime from sqlobject import * from turbogears import identity from turbogears.database import PackageHub hub = PackageHub("tglinks") __connection__ = hub # class YourDataClass(SQLObject): # pass class Visit(SQLObject): class sqlmeta: table = "visit" visit_key = StringCol(length=40, alternateID=True, alternateMethodName="by_visit_key") created = DateTimeCol(default=datetime.now) expiry = DateTimeCol() def lookup_visit(cls, visit_key): try: return cls.by_visit_key(visit_key) except SQLObjectNotFound: return None lookup_visit = classmethod(lookup_visit) class VisitIdentity(SQLObject): visit_key = StringCol(length=40, alternateID=True, alternateMethodName="by_visit_key") user_id = IntCol() class Group(SQLObject): """ An ultra-simple group definition. """ # 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_group" group_name = UnicodeCol(length=16, alternateID=True, alternateMethodName="by_group_name") display_name = UnicodeCol(length=255) created = DateTimeCol(default=datetime.now) # collection of all users belonging to this group users = RelatedJoin("User", intermediateTable="user_group", joinColumn="group_id", otherColumn="user_id") # collection of all permissions for this group permissions = RelatedJoin("Permission", joinColumn="group_id", intermediateTable="group_permission", otherColumn="permission_id") 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) bookmarks = MultipleJoin('Bookmark', joinColumn='user_id') # groups this user belongs to groups = RelatedJoin("Group", intermediateTable="user_group", joinColumn="user_id", otherColumn="group_id") def _get_permissions(self): perms = set() for g in self.groups: perms = perms | set(g.permissions) return perms def _set_password(self, cleartext_password): "Runs cleartext_password through the hash algorithm before saving." hash = identity.encrypt_password(cleartext_password) self._SO_set_password(hash) def set_password_raw(self, password): "Saves the password as-is to the database." self._SO_set_password(password) class Permission(SQLObject): permission_name = UnicodeCol(length=16, alternateID=True, alternateMethodName="by_permission_name") description = UnicodeCol(length=255) groups = RelatedJoin("Group", intermediateTable="group_permission", joinColumn="permission_id", otherColumn="group_id") class Tag(SQLObject): name = UnicodeCol(alternateID = True, length = 64) bookmarks = RelatedJoin('Bookmark') class Link(SQLObject): url = UnicodeCol(alternateID = True, length = 255) bookmarks = MultipleJoin('Bookmark') class Bookmark(SQLObject): user = ForeignKey('User') link = ForeignKey('Link') tags = RelatedJoin('Tag') title = UnicodeCol(length = 64) ======================================================= I'm using TurboGears B1, Postgresql 8.1, psycopg 1.1.21. Thanks! Nick Note: I attempted to post this earlier, and apologize if it shows up twice in the list. I just want to make sure it's getting out. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

