X-Git-Url: http://git.veekun.com/zzz-floof.git/blobdiff_plain/d4cccab138ed3ac57f90d3c2f6766de41a275f11..a058598f1ee11c60f9718d0ec677df1424be79c3:/floof/model/__init__.py diff --git a/floof/model/__init__.py b/floof/model/__init__.py index d0f03b3..22ceeaf 100644 --- a/floof/model/__init__.py +++ b/floof/model/__init__.py @@ -1,21 +1,30 @@ +# +# 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 + +elixir.session = meta.Session +Session = elixir.session +elixir.options_defaults.update({ 'autoload': True, 'shortnames': True }) -# Tables are defined in separate files and imported to here -from floof.model.users import * -from floof.model.art import * +metadata = elixir.metadata 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.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)