librelist archives

« back to archive

Implementing a Flask blueprint so that it can be safely mounted more than once?

Implementing a Flask blueprint so that it can be safely mounted more than once?

From:
Khalil El Kouhen
Date:
2013-01-24 @ 17:30
The Flask documentation says :

that you can register blueprints multiple times though not every blueprint
might respond properly to that. In fact it depends on how the blueprint is
implemented if it can be mounted more than once.

But I can't seem to find out what must be done to mount a blueprint more
than once.


-- 
Khalil EL KOUHEN
Directeur HEC Rabat
www.hec.ma  Tél.: 212 (0)5 37 67 12 76 Fax.: 212 (0)5 37 67 12 77

Re: [flask] Implementing a Flask blueprint so that it can be safely mounted more than once?

From:
薛 鹏飞
Date:
2013-01-30 @ 10:05
we have a project, it's our official blog, every post has a url prefix as 
~/post/xxx,
then our pm decided to use ~/blog/xxx, in this situation, you can register your 
blueprint with a different url prefix

--
Sincerely,
Pengfei Xue
https://life-map.rhcloud.com

在 2013-1-25,上午1:30,Khalil El Kouhen <khalil.elkouhen@gmail.com> 写道:

> The Flask documentation says :
> 
> that you can register blueprints multiple times though not every 
blueprint might respond properly to that. In fact it depends on how the 
blueprint is implemented if it can be mounted more than once.
> 
> But I can't seem to find out what must be done to mount a blueprint more
than once.
> 
> 
> 
> -- 
> Khalil EL KOUHEN
> Directeur HEC Rabat
> www.hec.ma  Tél.: 212 (0)5 37 67 12 76 Fax.: 212 (0)5 37 67 12 77

Re: [flask] Implementing a Flask blueprint so that it can be safely mounted more than once?

From:
Steven Kryskalla
Date:
2013-01-24 @ 17:37
On Thu, Jan 24, 2013 at 9:30 AM, Khalil El Kouhen
<khalil.elkouhen@gmail.com> wrote:
> The Flask documentation says :
>
> that you can register blueprints multiple times though not every blueprint
> might respond properly to that. In fact it depends on how the blueprint is
> implemented if it can be mounted more than once.
>
> But I can't seem to find out what must be done to mount a blueprint more
> than once.

I haven't come across anything special. The only thing I can think of
would be conflicting routes, but in that case you can use "url_prefix"
to mount the blueprints at different URLs.

Re: [flask] Implementing a Flask blueprint so that it can be safely mounted more than once?

From:
dorian i
Date:
2013-01-24 @ 17:47
To mount more than once just register more than once:

app.register_blueprint(bl)
app.register_blueprint(bl)

On Thu, Jan 24, 2013 at 6:37 PM, Steven Kryskalla <skryskalla@gmail.com>wrote:

> On Thu, Jan 24, 2013 at 9:30 AM, Khalil El Kouhen
> <khalil.elkouhen@gmail.com> wrote:
> > The Flask documentation says :
> >
> > that you can register blueprints multiple times though not every
> blueprint
> > might respond properly to that. In fact it depends on how the blueprint
> is
> > implemented if it can be mounted more than once.
> >
> > But I can't seem to find out what must be done to mount a blueprint more
> > than once.
>
> I haven't come across anything special. The only thing I can think of
> would be conflicting routes, but in that case you can use "url_prefix"
> to mount the blueprints at different URLs.
>