af26ba2d61d5b2ee5e421b242c89a0d124b7069f
[zzz-floof.git] / floof / model / __init__.py
1 """The application's model objects"""
2 import sqlalchemy as sa
3 from sqlalchemy import orm
4
5 from floof.model import meta
6
7 def init_model(engine):
8 """Call me before using any of the tables or classes in the model"""
9 ## Reflected tables must be defined and mapped here
10 #global reflected_table
11 #reflected_table = sa.Table("Reflected", meta.metadata, autoload=True,
12 # autoload_with=engine)
13 #orm.mapper(Reflected, reflected_table)
14 #
15 meta.Session.configure(bind=engine)
16 meta.engine = engine
17
18
19 ## Non-reflected tables may be defined and mapped at module level
20 #foo_table = sa.Table("Foo", meta.metadata,
21 # sa.Column("id", sa.types.Integer, primary_key=True),
22 # sa.Column("bar", sa.types.String(255), nullable=False),
23 # )
24 #
25 #class Foo(object):
26 # pass
27 #
28 #orm.mapper(Foo, foo_table)
29
30
31 ## Classes for reflected tables may be defined here, but the table and
32 ## mapping itself must be done in the init_model function
33 #reflected_table = None
34 #
35 #class Reflected(object):
36 # pass