diff options
| author | Simeon Simeonov | 2012-11-12 15:09:47 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2012-11-12 15:09:47 +0100 |
| commit | b1b484a0b93a5651da7d1ca20e77f70089b215bb (patch) | |
| tree | e254c380eff988b97062c6e196f29b61f42eb705 /bpynotify_orm.py | |
bpynotify - started
Diffstat (limited to 'bpynotify_orm.py')
| -rw-r--r-- | bpynotify_orm.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/bpynotify_orm.py b/bpynotify_orm.py new file mode 100644 index 0000000..0540d0a --- /dev/null +++ b/bpynotify_orm.py | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | # -*- coding: utf-8 -*- | ||
| 2 | |||
| 3 | import datetime | ||
| 4 | |||
| 5 | from sqlalchemy import schema, types | ||
| 6 | from sqlalchemy.orm import mapper | ||
| 7 | |||
| 8 | metadata = schema.MetaData() | ||
| 9 | |||
| 10 | notification_entry_table = schema.Table('notification_entries', metadata, | ||
| 11 | schema.Column('id', types.Integer, primary_key=True), | ||
| 12 | schema.Column('timestamp', types.DateTime), | ||
| 13 | schema.Column('message', types.Unicode(), default = u'Empty message'), | ||
| 14 | schema.Column('viewed', types.Boolean, default=False) | ||
| 15 | ) | ||
| 16 | |||
| 17 | |||
| 18 | |||
| 19 | class NotificationEntry(object): | ||
| 20 | |||
| 21 | def __init__(self, message): | ||
| 22 | |||
| 23 | self.timestamp = datetime.datetime.now() | ||
| 24 | self.message = message | ||
| 25 | |||
| 26 | |||
| 27 | def __repr__(self): | ||
| 28 | |||
| 29 | return message | ||
| 30 | |||
| 31 | |||
| 32 | mapper(NotificationEntry, notification_entry_table) | ||
