Re: [flask] Accessing 'app' in a Larger Application
- From:
- Kenshi Kawaguchi
- Date:
- 2011-03-13 @ 22:27
Hey Geoffry,
Take a look at the documentation for current_app. If you're configuring
your application in an app factory, chances are the app is not accessible at
import time.
http://flask.pocoo.org/docs/api/?highlight=current_app#flask.current_app
and
http://flask.pocoo.org/docs/patterns/appfactories/
On Sun, Mar 13, 2011 at 3:11 PM, Geoffry <vitron@gmail.com> wrote:
> Greetings,
>
> I followed the steps at http://flask.pocoo.org/docs/patterns/packages/ and
> now my project looks very much like this:
>
>
>> /yourapplication
>> -/yourapplication
>> --/__init__.py
>> --/views
>> --- __init__.py
>> --- admin.py
>> --- frontend.py
>> --/static
>> ---/style.css
>> --/templates
>> --- layout.html
>> --- index.html
>> --- login.html
>>
>> My question is, how do I access 'app' from inside frontend.py? For
> instance, to access the logger. If I try to import 'from project import app'
> I get a stack trace "ImportError: cannot import name app"
>
> Thanks for your help,
> - G
>
>