diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2010-05-04 02:22:10 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2010-05-04 02:22:10 +0200 |
commit | 91bb83da81a324727adf1de6190bc747a2f2e3d9 (patch) | |
tree | 039d7de9ffdbd6473c08a00d652be5784aaacd27 | |
parent | 06a8ad9c28502f64112ae8b067028bb6f5fe72b3 (diff) | |
download | kosten-91bb83da81a324727adf1de6190bc747a2f2e3d9.tar.gz kosten-91bb83da81a324727adf1de6190bc747a2f2e3d9.tar.bz2 kosten-91bb83da81a324727adf1de6190bc747a2f2e3d9.zip |
Some more relations
Diffstat (limited to '')
-rw-r--r-- | model.py | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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 |