summaryrefslogtreecommitdiff
path: root/model.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2010-05-04 02:22:10 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2010-05-04 02:22:10 +0200
commit91bb83da81a324727adf1de6190bc747a2f2e3d9 (patch)
tree039d7de9ffdbd6473c08a00d652be5784aaacd27 /model.py
parent06a8ad9c28502f64112ae8b067028bb6f5fe72b3 (diff)
downloadkosten-91bb83da81a324727adf1de6190bc747a2f2e3d9.tar.gz
kosten-91bb83da81a324727adf1de6190bc747a2f2e3d9.tar.bz2
kosten-91bb83da81a324727adf1de6190bc747a2f2e3d9.zip
Some more relations
Diffstat (limited to '')
-rw-r--r--model.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/model.py b/model.py
index 45e9296..02323b9 100644
--- a/model.py
+++ b/model.py
@@ -1,5 +1,5 @@
import elixir
-from elixir import Field, ManyToOne, ColumnProperty, using_options, using_options_defaults
+from elixir import Field, ManyToOne, OneToMany, OneToOne, ColumnProperty, using_options, using_options_defaults
from sqlalchemy import types as T
from functools import partial
@@ -18,8 +18,14 @@ class Category (Entity):
name = Field(T.String(50), unique = True)
+ parent = ManyToOne('Category')
+ children = OneToMany('Category')
+
def __repr__ (self):
- return '<Category "%s">' % self.name
+ if self.parent:
+ return '<Category "%s" of "%s">' % (self.name, self.parent.name)
+ else:
+ return '<Category "%s">' % self.name
class Expense (Entity):
using_options(abstract = True)
@@ -38,6 +44,9 @@ class ConstExpense (Expense):
monthly = ColumnProperty(lambda c: c.expense / c.months)
+ next = OneToOne('ConstExpense', inverse = 'prev')
+ prev = ManyToOne('ConstExpense')
+
elixir.setup_all()
session = elixir.session