librelist archives

« back to archive

Fwd: Re: [flask] Use create_app in a WSGI File!

Fwd: Re: [flask] Use create_app in a WSGI File!

From:
lynadge
Date:
2011-12-16 @ 11:09
Ok, i think i figured out.

Now, i init "create_app()" in "__init__.py" with "app = 
create_app(settings.Production)" and import this in the wsgi file and it 
works fine. But i think, this is not a good solution.

Here my new codes:

__init__.py: http://paste.pocoo.org/show/521654/
app.wsgi: http://paste.pocoo.org/show/521655/

I MUST use the name "app" in __init__.py, otherwise the import error 
appears and the wsgi file can not import the app. I tried alternative 
names and it does not work.

Now, when i'm in a developement phase, it creates on every time, an app 
object, i think, right?


Am 16.12.2011 10:00, schrieb Todd Kennedy:
> Your app does not provide create_app for the wsgi file to import.
>
> What happens if you try to import it manually from the python 
> interpreter?
>
> On Dec 16, 2011, at 3:44, lynadge <lynadge@barfooz.de> wrote:
>
>> No one can help?
>>
>> Am 14.12.2011 08:52, schrieb lynadge:
>>> Oh sorry.
>>>
>>> http://paste.pocoo.org/show/520624/
>>>
>>> Am 13.12.2011 17:16, schrieb Adam Patterson:
>>>> You didn't post the error you received. That would be helpful.
>>>>
>>>> On Tue, Dec 13, 2011 at 9:58 PM, lynadge <lynadge@barfooz.de> 
>>>> wrote:
>>>>> Hi,
>>>>>
>>>>> how can i use "create_app" in a wsgi file?
>>>>>
>>>>> I try to import it with "from app import create_app" but i got an
>>>>> error.
>>>>>
>>>>> My wsgi file looks like: http://paste.pocoo.org/show/520271/
>>>>>
>>>>> and my __init__.py: http://paste.pocoo.org/show/520272/
>>>>>
>>>>> My folder structure:
>>>>>     app.wsgi
>>>>>     app/
>>>>>         __init__.py
>>>>>
>>>>> I can't figure out where the problem is.
>>>>>
>>>>> I hope, someone can help me.
>>>>>
>>>>> greetz, lynadge
>>>>>
>>

Re: [flask] Use create_app in a WSGI File!

From:
Todd Kennedy
Date:
2011-12-16 @ 13:41
This pattern looks like its working; in my __init.py__ for my flask
projects it just does the app initiation inline not as part of a
function -- when I import the base package my intent is always to
create an instance of a flask app. Being that without creating the
instance you can't run it.

On Dec 16, 2011, at 6:12, lynadge <lynadge@barfooz.de> wrote:

> Ok, i think i figured out.
>
> Now, i init "create_app()" in "__init__.py" with "app =
> create_app(settings.Production)" and import this in the wsgi file and it
> works fine. But i think, this is not a good solution.
>
> Here my new codes:
>
> __init__.py: http://paste.pocoo.org/show/521654/
> app.wsgi: http://paste.pocoo.org/show/521655/
>
> I MUST use the name "app" in __init__.py, otherwise the import error
> appears and the wsgi file can not import the app. I tried alternative
> names and it does not work.
>
> Now, when i'm in a developement phase, it creates on every time, an app
> object, i think, right?
>
>
> Am 16.12.2011 10:00, schrieb Todd Kennedy:
>> Your app does not provide create_app for the wsgi file to import.
>>
>> What happens if you try to import it manually from the python
>> interpreter?
>>
>> On Dec 16, 2011, at 3:44, lynadge <lynadge@barfooz.de> wrote:
>>
>>> No one can help?
>>>
>>> Am 14.12.2011 08:52, schrieb lynadge:
>>>> Oh sorry.
>>>>
>>>> http://paste.pocoo.org/show/520624/
>>>>
>>>> Am 13.12.2011 17:16, schrieb Adam Patterson:
>>>>> You didn't post the error you received. That would be helpful.
>>>>>
>>>>> On Tue, Dec 13, 2011 at 9:58 PM, lynadge <lynadge@barfooz.de>
>>>>> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> how can i use "create_app" in a wsgi file?
>>>>>>
>>>>>> I try to import it with "from app import create_app" but i got an
>>>>>> error.
>>>>>>
>>>>>> My wsgi file looks like: http://paste.pocoo.org/show/520271/
>>>>>>
>>>>>> and my __init__.py: http://paste.pocoo.org/show/520272/
>>>>>>
>>>>>> My folder structure:
>>>>>>    app.wsgi
>>>>>>    app/
>>>>>>        __init__.py
>>>>>>
>>>>>> I can't figure out where the problem is.
>>>>>>
>>>>>> I hope, someone can help me.
>>>>>>
>>>>>> greetz, lynadge
>>>>>>
>>>
>