diff options
author | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2012-01-05 00:18:17 +0100 |
---|---|---|
committer | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2012-01-08 21:55:46 +0100 |
commit | f42e49c3ad1c446e7899e7b76cd7fa381d5bba7c (patch) | |
tree | afe23990c6bcff4566474e6c075eb81d4562adae /mediagoblin/db/sql/models.py | |
parent | bcd50908d2849dff5a466b15db65112779cb85e2 (diff) | |
download | mediagoblin-f42e49c3ad1c446e7899e7b76cd7fa381d5bba7c.tar.lz mediagoblin-f42e49c3ad1c446e7899e7b76cd7fa381d5bba7c.tar.xz mediagoblin-f42e49c3ad1c446e7899e7b76cd7fa381d5bba7c.zip |
Add DB Mixin classes and use them
A bunch of functions on the db objects are really more like
"utility functions": They could live outside the classes
and be called "by hand" passing the appropiate reference.
They usually only use the public API of the object and
rarely use database related stuff.
Goals:
- First, simple: Share the code with the SQL objects, so
that the code doesn't need to be duplicated.
- Second, it might unclutter the db models and make them
more into "model only" stuff.
- Doesn't really hurt.
Diffstat (limited to 'mediagoblin/db/sql/models.py')
-rw-r--r-- | mediagoblin/db/sql/models.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/mediagoblin/db/sql/models.py b/mediagoblin/db/sql/models.py index 31a6ed3b..95821b4f 100644 --- a/mediagoblin/db/sql/models.py +++ b/mediagoblin/db/sql/models.py @@ -7,6 +7,7 @@ from sqlalchemy import ( from sqlalchemy.orm import relationship from mediagoblin.db.sql.base import GMGTableBase +from mediagoblin.db.mixin import UserMixin, MediaEntryMixin Base = declarative_base(cls=GMGTableBase) @@ -24,7 +25,7 @@ class SimpleFieldAlias(object): setattr(instance, self.fieldname, val) -class User(Base): +class User(Base, UserMixin): __tablename__ = "users" id = Column(Integer, primary_key=True) @@ -48,7 +49,7 @@ class User(Base): _id = SimpleFieldAlias("id") -class MediaEntry(Base): +class MediaEntry(Base, MediaEntryMixin): __tablename__ = "media_entries" id = Column(Integer, primary_key=True) |