summaryrefslogtreecommitdiff
path: root/data.py
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2015-11-22 00:25:56 +0100
committerYves Fischer <yvesf-git@xapek.org>2015-11-22 00:25:56 +0100
commit6080b38fb2b6b3c1017bdd34bb7552bc7e26a4a0 (patch)
tree07b69c3c6a665ef290591e184ca0d2ba3b73fe01 /data.py
parent49ac3c20cb77b90493ce79b4e31cf0f58cba0116 (diff)
downloadwatchnews-6080b38fb2b6b3c1017bdd34bb7552bc7e26a4a0.tar.gz
watchnews-6080b38fb2b6b3c1017bdd34bb7552bc7e26a4a0.zip
project restructure
make it a proper python package
Diffstat (limited to 'data.py')
-rw-r--r--data.py41
1 files changed, 0 insertions, 41 deletions
diff --git a/data.py b/data.py
deleted file mode 100644
index c1d2e82..0000000
--- a/data.py
+++ /dev/null
@@ -1,41 +0,0 @@
-import os
-import datetime
-import peewee as p
-import re
-
-class SqliteDatabase(p.SqliteDatabase):
- foreign_keys = True
- def _add_conn_hooks(self, conn):
- p.SqliteDatabase._add_conn_hooks(self, conn)
- conn.execute('PRAGMA foreign_keys = ON;').fetchone()
-
-db = p.Proxy()
-
-class BaseModel(p.Model):
- class Meta:
- database = db
- def __json__(self):
- return self._data
- def __repr__(self):
- return "<{.__class__.__name__} {}>".format(self, " ".join(
- map(lambda kv: "{0[0]}={0[1]}".format(kv), self._data.items())))
-
-class Feed(BaseModel):
- created_date = p.DateTimeField(default=datetime.datetime.now)
- url = p.CharField(unique=True)
- title = p.CharField(null=True)
-
-class Item(BaseModel):
- created_date = p.DateTimeField(default=datetime.datetime.now)
- feed = p.ForeignKeyField(Feed, related_name='items', on_delete='CASCADE')
- uid = p.CharField()
- title = p.CharField(null=True)
-
-class Version(BaseModel):
- created_date = p.DateTimeField(default=datetime.datetime.now)
- item = p.ForeignKeyField(Item, related_name='versions', on_delete='CASCADE')
- url = p.CharField()
- title = p.CharField()
- authors = p.CharField()
- text = p.CharField()
-