librelist archives

« back to archive

Accessing the application object from a blueprint

Accessing the application object from a blueprint

From:
Frédéric Back
Date:
2011-07-14 @ 09:14
Hello, 

what would be the proper way to access the application object from a
blueprint? More specifically, I would like to access the application's
configuration from a blueprint.

Thanks!
Fred


Re: [flask] Accessing the application object from a blueprint

From:
Daniel , Dao Quang Minh
Date:
2011-07-14 @ 09:23
`current_app` might help

http://flask.pocoo.org/docs/api/#flask.current_app

2011/7/14 Frédéric Back <frederic.back@tetraeder.com>

> Hello,
>
> what would be the proper way to access the application object from a
> blueprint? More specifically, I would like to access the application's
> configuration from a blueprint.
>
> Thanks!
> Fred
>
>
>
>

Re: [flask] Accessing the application object from a blueprint

From:
Frédéric Back
Date:
2011-07-14 @ 09:34
It does. Thanks!

On Do, 2011-07-14 at 17:23 +0800, Daniel , Dao Quang Minh wrote:
> `current_app` might help
> 
> http://flask.pocoo.org/docs/api/#flask.current_app
> 
> 2011/7/14 Frédéric Back <frederic.back@tetraeder.com>
>         Hello,
>         
>         what would be the proper way to access the application object
>         from a
>         blueprint? More specifically, I would like to access the
>         application's
>         configuration from a blueprint.
>         
>         Thanks!
>         Fred
>         
>         
>         
> 
> 

Re: [flask] Accessing the application object from a blueprint

From:
Ishbir Singh
Date:
2011-07-14 @ 10:01
Hey,

I know this would create a circular dependancy, but it works just fine.

2011/7/14 Frédéric Back <frederic.back@tetraeder.com>

> It does. Thanks!
>
> On Do, 2011-07-14 at 17:23 +0800, Daniel , Dao Quang Minh wrote:
> > `current_app` might help
> >
> > http://flask.pocoo.org/docs/api/#flask.current_app
> >
> > 2011/7/14 Frédéric Back <frederic.back@tetraeder.com>
> >         Hello,
> >
> >         what would be the proper way to access the application object
> >         from a
> >         blueprint? More specifically, I would like to access the
> >         application's
> >         configuration from a blueprint.
> >
> >         Thanks!
> >         Fred
> >
> >
> >
> >
> >
>
>
>


-- 
Regards,
Ishbir Singh

Re: [flask] Accessing the application object from a blueprint

From:
Ishbir Singh
Date:
2011-07-14 @ 09:18
Hey,

Why not just import the app object from the respective module?

2011/7/14 Frédéric Back <frederic.back@tetraeder.com>

> Hello,
>
> what would be the proper way to access the application object from a
> blueprint? More specifically, I would like to access the application's
> configuration from a blueprint.
>
> Thanks!
> Fred
>
>
>
>


-- 
Regards,
Ishbir Singh

Re: [flask] Accessing the application object from a blueprint

From:
Frédéric Back
Date:
2011-07-14 @ 09:30
In my case, that would create a circular dependency, since the main
application imports the blueprint. 

Of course, I could simply import the configuration from a common module
or something, but wouldn't that break the purpose of the blueprint? To
be modular enough to work in different applications?

It seems to me that accessing the application's config directly would be
the cleanest way to solve my problem, but I'm unsure if this is even
possible.


On Do, 2011-07-14 at 14:48 +0530, Ishbir Singh wrote:
> Hey,
> 
> Why not just import the app object from the respective module?
> 
> 2011/7/14 Frédéric Back <frederic.back@tetraeder.com>
>         Hello,
>         
>         what would be the proper way to access the application object
>         from a
>         blueprint? More specifically, I would like to access the
>         application's
>         configuration from a blueprint.
>         
>         Thanks!
>         Fred
>         
>         
>         
> 
> 
> 
> -- 
> Regards,
> Ishbir Singh
>