X-Git-Url: http://git.veekun.com/zzz-floof.git/blobdiff_plain/a058598f1ee11c60f9718d0ec677df1424be79c3..bb380b3d5ca425650bb86c1fef45d4ca9fde3b25:/floof/model/__init__.py diff --git a/floof/model/__init__.py b/floof/model/__init__.py index 22ceeaf..1a81770 100644 --- a/floof/model/__init__.py +++ b/floof/model/__init__.py @@ -1,30 +1,32 @@ -# -# floof/floof/model/__init__.py -# -# Copyright (c) 2009 Scribblr -# -# See: http://bel-epa.com/docs/elixir_pylons/ -# - """The application's model objects""" - -from floof.model import art, users -from floof.model import meta import elixir +from floof.model import meta -elixir.session = meta.Session -Session = elixir.session -elixir.options_defaults.update({ 'autoload': True, 'shortnames': True }) - +Session = elixir.session = meta.Session +# Uncomment if using reflected tables +# elixir.options_defaults.update({'autoload': True}) +elixir.options_defaults.update({'shortnames':True}) metadata = elixir.metadata +# this will be called in config/environment.py +# if not using reflected tables def init_model(engine): - elixir.session.configure(bind=engine) + """Call me before using any of the tables or classes in the model""" + meta.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) +# Delay the setup if using reflected tables +if elixir.options_defaults.get('autoload', False) \ + and not metadata.is_bound(): + elixir.delay_setup = True + +# # import other entities here, e.g. +# from floof.model.blog import BlogEntry, BlogComment +from floof.model import art, users, search + +# Finally, call elixir to set up the tables. +# but not if using reflected tables +if not elixir.options_defaults.get('autoload', False): + elixir.setup_all() +