more app factory help
- Matthew Hoopes
- 2013-08-26 @ 14:27
I was recently helped on this list (
and I was hoping for a bit more advice.
I've currently got a create_app function for my application factory, and
have been trying to untangle imports so nothing imported needs the config
before I have a proper context.
My current problem is that I have some models that live in databases that
are doing cross-database joins. Similar to
The problem is that my schema name may change based on the config, so
don't have it when attempting to define the models, which are imported and
used in a view. This view is imported before the application context is
created - so I have a chicken-and-egg problem.
Re-stated: The view is imported in create_app, which imports the model, but
the model needs the config from the app context, which isn't created until
(Note - I could be missing something obvious here)
I've also tried the appcontext_pushed signal, but it looks like routing
might have to be set up before that?
Another solution to the problem might also be forcing sqlalchemy to always
emit the schema name when building the query, and not set the schema name
in the __table_args__ manually. If anyone has any advice on that, I'd be
Anyway - any help is greatly appreciated, as always!