+#
+# floof/floof/model/__init__.py
+#
+# Copyright (c) 2009 Scribblr
+#
+# See: http://bel-epa.com/docs/elixir_pylons/
+#
+
"""The application's model objects"""
-import sqlalchemy as sa
-from sqlalchemy import orm
+from floof.model import art, users
from floof.model import meta
+import elixir
-def init_model(engine):
- """Call me before using any of the tables or classes in the model"""
- ## Reflected tables must be defined and mapped here
- #global reflected_table
- #reflected_table = sa.Table("Reflected", meta.metadata, autoload=True,
- # autoload_with=engine)
- #orm.mapper(Reflected, reflected_table)
- #
- meta.Session.configure(bind=engine)
- meta.engine = engine
+elixir.session = meta.Session
+Session = elixir.session
+elixir.options_defaults.update({ 'autoload': True, 'shortnames': True })
+metadata = elixir.metadata
-## Non-reflected tables may be defined and mapped at module level
-#foo_table = sa.Table("Foo", meta.metadata,
-# sa.Column("id", sa.types.Integer, primary_key=True),
-# sa.Column("bar", sa.types.String(255), nullable=False),
-# )
-#
-#class Foo(object):
-# pass
-#
-#orm.mapper(Foo, foo_table)
+def init_model(engine):
+ elixir.session.configure(bind=engine)
+ metadata.bind = engine
+ if elixir.options_defaults.get('autoload', False):
+ if not metadata.is_bound():
+ elixir.delay_setup = True
+ else:
+ elixir.setup_all(True)
-## Classes for reflected tables may be defined here, but the table and
-## mapping itself must be done in the init_model function
-#reflected_table = None
-#
-#class Reflected(object):
-# pass