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 #734 (closed defect: invalid)

Opened 13 years ago

Last modified 12 years ago

"no such table: tg_user " error

Reported by: Italo.Maia Owned by: anonymous
Priority: normal Milestone: 0.9a5
Component: Identity Version: 0.9a4
Severity: blocker Keywords: tg_user, user
Cc:

Description

Can't add users to database because a no such table error is throw! Here's a piece of my model:

from turbogears.identity.soprovider import TG_User, TG_Group, TG_Permission
from datetime import datetime


hub = PackageHub("wiki")
__connection__ = hub


class Usuario(TG_User):
    nome_completo=UnicodeCol(length=255,notNone=True)   

Here's a piece of my app.cfg:

identity.soprovider.model.user="wiki.model.Usuario"
identity.soprovider.model.group="wiki.model.Grupo"
identity.soprovider.model.permission="wiki.model.Permissao"

Change History

comment:1 Changed 13 years ago by godoy

07/Apr/2006:01:13:08 CONFIG INFO Server parameters:
07/Apr/2006:01:13:08 CONFIG INFO   server.environment: development
07/Apr/2006:01:13:08 CONFIG INFO   server.log_to_screen: True
07/Apr/2006:01:13:08 CONFIG INFO   server.log_file: 
07/Apr/2006:01:13:08 CONFIG INFO   server.log_tracebacks: True
07/Apr/2006:01:13:08 CONFIG INFO   server.log_request_headers: True
07/Apr/2006:01:13:08 CONFIG INFO   server.protocol_version: HTTP/1.0
07/Apr/2006:01:13:08 CONFIG INFO   server.socket_host: 
07/Apr/2006:01:13:08 CONFIG INFO   server.socket_port: 8080
07/Apr/2006:01:13:08 CONFIG INFO   server.socket_file: 
07/Apr/2006:01:13:08 CONFIG INFO   server.reverse_dns: False
07/Apr/2006:01:13:08 CONFIG INFO   server.socket_queue_size: 5
07/Apr/2006:01:13:08 CONFIG INFO   server.thread_pool: 10
2006-04-07 01:13:08,632 turbogears.visit INFO Visit Tracking starting
2006-04-07 01:13:08,632 turbogears.visit DEBUG Loading visit manager from plugin: sqlobject
2006-04-07 01:13:08,636 turbogears.visit INFO Visit filter initialised
2006-04-07 01:13:08,649 turbogears.identity INFO Identity starting
2006-04-07 01:13:08,649 turbogears.identity DEBUG Loading provider from plugin: sqlobject
2006-04-07 01:13:08,703 turbogears.identity.soprovider INFO Succesfully loaded "test_app.model.Usuario"
2006-04-07 01:13:08,704 turbogears.identity.soprovider INFO Succesfully loaded "turbogears.identity.soprovider.TG_Group"
2006-04-07 01:13:08,704 turbogears.identity.soprovider INFO Succesfully loaded "turbogears.identity.soprovider.TG_Permission"
2006-04-07 01:13:08,841 turbogears.identity INFO Identity visit plugin initialised
2006-04-07 01:13:08,842 turbogears.identity DEBUG Loading provider from plugin: sqlobject
2006-04-07 01:13:08,845 turbogears.identity.soprovider INFO Succesfully loaded "test_app.model.Usuario"
2006-04-07 01:13:08,845 turbogears.identity.soprovider INFO Succesfully loaded "turbogears.identity.soprovider.TG_Group"
2006-04-07 01:13:08,846 turbogears.identity.soprovider INFO Succesfully loaded "turbogears.identity.soprovider.TG_Permission"
07/Apr/2006:01:13:08 HTTP INFO Serving HTTP on http://localhost:8080/

Tested with the given code on this bug report and everything worked as expected. I used the procedure described on the Wiki:

  • enabled identity and visit, started the app
  • changed the model
  • restarted the app

As it can be seen above, more specifically on the line

2006-04-07 01:13:08,845 turbogears.identity.soprovider INFO Succesfully loaded "test_app.model.Usuario"

it worked without any problem. Tables were created and the user was added.

comment:2 Changed 13 years ago by godoy

I forgot posting the contents of the database. I used sqlite for the test:

sqlite> .databases
seq  name             file                                                      
---  ---------------  ----------------------------------------------------------
0    main             /home/godoy/tmp/test_app.db                               
sqlite> .dump
BEGIN TRANSACTION;
CREATE TABLE tg_visit (
    id INTEGER PRIMARY KEY,
    visit_key VARCHAR(40) NOT NULL UNIQUE,
    created TIMESTAMP,
    expiry TIMESTAMP
);
INSERT INTO "tg_visit" VALUES(1, 'ffec5f6b4d48983ae8e9996f2bb8477d06e42437', '2006-04-07 01:29:05', '2006-04-07 01:49:29');
CREATE TABLE tg_user (
    id INTEGER PRIMARY KEY,
    child_name VARCHAR(255),
    user_id VARCHAR(16) NOT NULL UNIQUE,
    email_address VARCHAR(255) NOT NULL UNIQUE,
    display_name VARCHAR(255),
    password VARCHAR(40),
    created TIMESTAMP
);
INSERT INTO "tg_user" VALUES(1, 'Usuario', 'godoy', 'godoy@g2ctech.com', 'godoy', 'teste', '2006-04-07 01:29:00');
CREATE TABLE tg_group (
    id INTEGER PRIMARY KEY,
    child_name VARCHAR(255),
    group_id VARCHAR(16) NOT NULL UNIQUE,
    display_name VARCHAR(255),
    created TIMESTAMP
);
CREATE TABLE tg_user_group (
group_id INT NOT NULL,
user_id INT NOT NULL
);
CREATE TABLE tg_group_permission (
group_id INT NOT NULL,
permission_id INT NOT NULL
);
CREATE TABLE tg_group_permission (
group_id INT NOT NULL,
permission_id INT NOT NULL
);
CREATE TABLE tg_permission (
    id INTEGER PRIMARY KEY,
    child_name VARCHAR(255),
    permission_id VARCHAR(16) NOT NULL UNIQUE,
    description VARCHAR(255)
);
CREATE TABLE tg_visit_identity (
    id INTEGER PRIMARY KEY,
    visit_id INT NOT NULL UNIQUE,
    user_id INT
);
CREATE TABLE usuario (
    id INTEGER PRIMARY KEY,
    child_name VARCHAR(255),
    nome_completo VARCHAR(255) NOT NULL
);
INSERT INTO "usuario" VALUES(1, NULL, 'Jorge Godoy');
COMMIT;
sqlite> 

comment:3 Changed 13 years ago by Try it out like this:

Try it out starting the app only once

comment:4 Changed 13 years ago by godoy

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

The reporter of the bug said that it worked on the mailing list after following the wiki recommendations.

comment:5 Changed 13 years ago by kov@…

What wiki recommendations?

I'm trying this code:

from sqlobject import *
from datetime import datetime
from turbogears.database import PackageHub
from turbogears.identity.soprovider import TG_User, TG_Group, TG_Permission, TG_VisitIdentity

hub = PackageHub("buzzword")
__connection__ = hub

class Category(SQLObject):
    name = UnicodeCol(unique=True,notNone=True)
    description = UnicodeCol()
    icon = BLOBCol()
    posts = RelatedJoin("Post")


class Author(TG_User):
    hackergotchi = BLOBCol()
    url = UnicodeCol()
    posts = MultipleJoin("Post",joinColumn='author_id')
    comments = MultipleJoin("Comment",joinColumn='author_id')

class Group(TG_Group):
    class sqlmeta:
        table = 'bz_group'
    pass

class Permission(TG_Permission):
    pass

class VisitIdentity(TG_VisitIdentity):
    pass

class Comment(SQLObject):
    title = UnicodeCol()
    content = UnicodeCol(notNone=True)
    timestamp = DateTimeCol(default=datetime.now)
    post = ForeignKey("Post")
    author = ForeignKey("Author")
    visitor = ForeignKey("Visitor")


class Post(SQLObject):
    timestamp = DateTimeCol(default=datetime.now)
    title = UnicodeCol()
    content = UnicodeCol()
    author = ForeignKey("Author")
    categories = RelatedJoin("Category")
    display = BoolCol(default="True")
    comments = MultipleJoin("Comment",joinColumn='post_id')


class Visitor(SQLObject):
    name = UnicodeCol(notNone=True)
    email = UnicodeCol(unique=False,notNone=True)
    url = UnicodeCol()
    comments = MultipleJoin("Comment",joinColumn='visitor_id')

And tg-admin sql create generates this:

sqlite> .dump
BEGIN TRANSACTION;
CREATE TABLE author (
    id INTEGER PRIMARY KEY,
    hackergotchi TEXT,
    url TEXT,
    child_name VARCHAR(255)
);
CREATE TABLE category (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL UNIQUE,
    description TEXT,
    icon TEXT
);
CREATE TABLE category_post (
category_id INT NOT NULL,
post_id INT NOT NULL
);
CREATE TABLE comment (
    id INTEGER PRIMARY KEY,
    title TEXT,
    content TEXT NOT NULL,
    timestamp TIMESTAMP,
    post_id INT CONSTRAINT post_id_exists REFERENCES post(id) ,
    author_id INT CONSTRAINT author_id_exists REFERENCES author(id) ,
    visitor_id INT CONSTRAINT visitor_id_exists REFERENCES visitor(id)
); 
CREATE TABLE bz_group (
    id INTEGER PRIMARY KEY,
    child_name VARCHAR(255)
);
CREATE TABLE permission (
    id INTEGER PRIMARY KEY,
    child_name VARCHAR(255)
);
CREATE TABLE post (
    id INTEGER PRIMARY KEY,
    timestamp TIMESTAMP,
    title TEXT,
    content TEXT,
    author_id INT CONSTRAINT author_id_exists REFERENCES author(id) ,
    display TINYINT
);
CREATE TABLE visit_identity (
    id INTEGER PRIMARY KEY,
    visit_key VARCHAR(40) NOT NULL UNIQUE,
    user_id INT
);
CREATE TABLE visitor (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL,
    email TEXT NOT NULL,
    url TEXT
);
COMMIT;

I'm a bit lost.

Note: See TracTickets for help on using tickets.