diff options
author | Priit Laes <plaes@plaes.org> | 2010-07-01 14:41:24 +0300 |
---|---|---|
committer | Priit Laes <plaes@plaes.org> | 2010-07-01 23:50:28 +0300 |
commit | 5102b71d333934ded46c6e0e0eb1386014926882 (patch) | |
tree | 29568b41ac27e2f20e961bebb642c207fad8f4ee | |
parent | Fix some typos (diff) | |
download | gsoc2010-grumpy-5102b71d333934ded46c6e0e0eb1386014926882.tar.gz gsoc2010-grumpy-5102b71d333934ded46c6e0e0eb1386014926882.tar.bz2 gsoc2010-grumpy-5102b71d333934ded46c6e0e0eb1386014926882.zip |
Added Setting class/table to data model
-rw-r--r-- | grumpy/models.py | 22 | ||||
-rwxr-xr-x | utils/grumpy_sync.py | 3 |
2 files changed, 23 insertions, 2 deletions
diff --git a/grumpy/models.py b/grumpy/models.py index 425a117..d964a87 100644 --- a/grumpy/models.py +++ b/grumpy/models.py @@ -11,10 +11,13 @@ """ from datetime import datetime -from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, Table +from sqlalchemy import (Column, DateTime, ForeignKey, Integer, String, \ + Table, Text) from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declarative_base +import json + Base = declarative_base() # Association tables @@ -85,6 +88,23 @@ class Ebuild(Base): def __repr__(self): return '<%s> - %s' % (self.__class__.__name__, self.cpv) +class Setting(Base): + """Housekeeping table for storing various system settings and info.""" + + __tablename__ = 'settings' + + name = Column('name', String, primary_key=True, unique=True) + rawdata = Column('data', Text) + + def __init__(self, name, data): + self.name = name + self.rawdata = json.dumps(data) + + @property + def data(self): + return json.loads(data) + + class Herd(Base): """Represents herds in the system""" diff --git a/utils/grumpy_sync.py b/utils/grumpy_sync.py index ed506a1..7da95c8 100755 --- a/utils/grumpy_sync.py +++ b/utils/grumpy_sync.py @@ -18,7 +18,8 @@ path = os.path.join(os.path.dirname(__file__), os.path.pardir) sys.path.insert(0, path) del path -from grumpy.models import Base, Category, Developer, Ebuild, Herd, Package +from grumpy.models import (Base, Category, Developer, Ebuild, Herd, + Package, Setting) def main(path): engine = create_engine('postgresql://grumpy:grumpy@localhost/grumpy') |