Mercurial > kallithea
annotate pylons_app/model/db.py @ 275:2d61aa00e855
fixed bugs when putting empty or unknown changesets into diff
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 09 Jun 2010 08:07:05 +0200 |
parents | 0e5455fda8fd |
children | 29370bb76fa6 |
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 * |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
4 from vcs.utils.lazy import LazyProperty |
49
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
5 |
234
a0116e944da1
changed naming convention for db modules.
Marcin Kuzminski <marcin@python-works.com>
parents:
232
diff
changeset
|
6 class User(Base): |
49
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
7 __tablename__ = 'users' |
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
8 __table_args__ = {'useexisting':True} |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
9 user_id = Column("user_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True) |
89
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
10 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
|
11 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
|
12 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
|
13 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
|
14 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
|
15 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
|
16 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
|
17 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
|
18 |
234
a0116e944da1
changed naming convention for db modules.
Marcin Kuzminski <marcin@python-works.com>
parents:
232
diff
changeset
|
19 user_log = relation('UserLog') |
232
37a832dc4a82
some beaker cache changes, and added repr to models
Marcin Kuzminski <marcin@python-works.com>
parents:
226
diff
changeset
|
20 |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
21 @LazyProperty |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
22 def full_contact(self): |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
23 return '%s %s <%s>' % (self.name, self.lastname, self.email) |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
24 |
232
37a832dc4a82
some beaker cache changes, and added repr to models
Marcin Kuzminski <marcin@python-works.com>
parents:
226
diff
changeset
|
25 def __repr__(self): |
37a832dc4a82
some beaker cache changes, and added repr to models
Marcin Kuzminski <marcin@python-works.com>
parents:
226
diff
changeset
|
26 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
|
27 |
234
a0116e944da1
changed naming convention for db modules.
Marcin Kuzminski <marcin@python-works.com>
parents:
232
diff
changeset
|
28 class UserLog(Base): |
49
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
29 __tablename__ = 'user_logs' |
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
30 __table_args__ = {'useexisting':True} |
234
a0116e944da1
changed naming convention for db modules.
Marcin Kuzminski <marcin@python-works.com>
parents:
232
diff
changeset
|
31 user_log_id = Column("user_log_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=1) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
32 user_id = Column("user_id", INTEGER(), ForeignKey(u'users.user_id'), nullable=False, unique=None, default=None) |
89
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
33 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
|
34 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
|
35 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
|
36 |
234
a0116e944da1
changed naming convention for db modules.
Marcin Kuzminski <marcin@python-works.com>
parents:
232
diff
changeset
|
37 user = relation('User') |
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
|
38 |
234
a0116e944da1
changed naming convention for db modules.
Marcin Kuzminski <marcin@python-works.com>
parents:
232
diff
changeset
|
39 class Repository(Base): |
a0116e944da1
changed naming convention for db modules.
Marcin Kuzminski <marcin@python-works.com>
parents:
232
diff
changeset
|
40 __tablename__ = 'repositories' |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
41 repo_name = Column("repo_name", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=False, unique=True, default=None, primary_key=True) |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
42 user_id = Column("user_id", INTEGER(), ForeignKey(u'users.user_id'), nullable=False, unique=False, default=None) |
242
5da4ef115006
Added lastlogin to user after login, model db update
Marcin Kuzminski <marcin@python-works.com>
parents:
239
diff
changeset
|
43 private = Column("private", BOOLEAN(), nullable=True, unique=None, default=None) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
44 description = Column("description", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
242
5da4ef115006
Added lastlogin to user after login, model db update
Marcin Kuzminski <marcin@python-works.com>
parents:
239
diff
changeset
|
45 user = relation('User') |
5da4ef115006
Added lastlogin to user after login, model db update
Marcin Kuzminski <marcin@python-works.com>
parents:
239
diff
changeset
|
46 |
234
a0116e944da1
changed naming convention for db modules.
Marcin Kuzminski <marcin@python-works.com>
parents:
232
diff
changeset
|
47 class Permission(Base): |
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
|
48 __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
|
49 __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
|
50 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
|
51 permission_name = Column("permission_name", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
239
b18f89d6d17f
Adde draft for permissions systems, made all needed decorators, and checks. For future usage in the system.
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
52 permission_longname = Column("permission_longname", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
b18f89d6d17f
Adde draft for permissions systems, made all needed decorators, and checks. For future usage in the system.
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
53 |
232
37a832dc4a82
some beaker cache changes, and added repr to models
Marcin Kuzminski <marcin@python-works.com>
parents:
226
diff
changeset
|
54 def __repr__(self): |
37a832dc4a82
some beaker cache changes, and added repr to models
Marcin Kuzminski <marcin@python-works.com>
parents:
226
diff
changeset
|
55 return "<Permission('%s:%s')>" % (self.permission_id, self.permission_name) |