Mercurial > kallithea
annotate pylons_app/model/db.py @ 232:37a832dc4a82
some beaker cache changes, and added repr to models
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 27 May 2010 16:00:47 +0200 |
parents | c6526b7531e9 |
children | a0116e944da1 |
rev | line source |
---|---|
89
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
1 from pylons_app.model.meta import Base |
49
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
2 from sqlalchemy.orm import relation, backref |
226
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
3 from sqlalchemy import * |
49
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
4 |
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
5 class Users(Base): |
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
6 __tablename__ = 'users' |
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
7 __table_args__ = {'useexisting':True} |
89
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
8 user_id = Column("user_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=1) |
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
9 username = Column("username", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
10 password = Column("password", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
11 active = Column("active", BOOLEAN(), nullable=True, unique=None, default=None) |
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
12 admin = Column("admin", BOOLEAN(), nullable=True, unique=None, default=None) |
226
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
13 name = Column("name", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
14 lastname = Column("lastname", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
15 email = Column("email", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
16 last_login = Column("last_login", DATETIME(timezone=False), nullable=True, unique=None, default=None) |
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
17 |
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
18 user_log = relation('UserLogs') |
232
37a832dc4a82
some beaker cache changes, and added repr to models
Marcin Kuzminski <marcin@python-works.com>
parents:
226
diff
changeset
|
19 |
37a832dc4a82
some beaker cache changes, and added repr to models
Marcin Kuzminski <marcin@python-works.com>
parents:
226
diff
changeset
|
20 def __repr__(self): |
37a832dc4a82
some beaker cache changes, and added repr to models
Marcin Kuzminski <marcin@python-works.com>
parents:
226
diff
changeset
|
21 return "<User('%s:%s')>" % (self.user_id, self.username) |
61
1b6d7662d6e2
Updated database model, with FK and Booleans
Marcin Kuzminski <marcin@python-blog.com>
parents:
49
diff
changeset
|
22 |
49
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
23 class UserLogs(Base): |
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
24 __tablename__ = 'user_logs' |
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
25 __table_args__ = {'useexisting':True} |
226
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
26 user_log_id = Column("id", INTEGER(), nullable=False, unique=True, default=None, primary_key=1) |
89
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
27 user_id = Column("user_id", INTEGER(), ForeignKey(u'users.user_id'), nullable=True, unique=None, default=None) |
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
28 repository = Column("repository", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
29 action = Column("action", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
30 action_date = Column("action_date", DATETIME(timezone=False), nullable=True, unique=None, default=None) |
226
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
31 |
61
1b6d7662d6e2
Updated database model, with FK and Booleans
Marcin Kuzminski <marcin@python-blog.com>
parents:
49
diff
changeset
|
32 user = relation('Users') |
226
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
33 |
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
34 |
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
35 class Permissions(Base): |
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
36 __tablename__ = 'permissions' |
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
37 __table_args__ = {'useexisting':True} |
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
38 permission_id = Column("id", INTEGER(), nullable=False, unique=True, default=None, primary_key=1) |
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
39 permission_name = Column("permission_name", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
232
37a832dc4a82
some beaker cache changes, and added repr to models
Marcin Kuzminski <marcin@python-works.com>
parents:
226
diff
changeset
|
40 |
37a832dc4a82
some beaker cache changes, and added repr to models
Marcin Kuzminski <marcin@python-works.com>
parents:
226
diff
changeset
|
41 def __repr__(self): |
37a832dc4a82
some beaker cache changes, and added repr to models
Marcin Kuzminski <marcin@python-works.com>
parents:
226
diff
changeset
|
42 return "<Permission('%s:%s')>" % (self.permission_id, self.permission_name) |