On Fri, Apr 4, 2014 at 3:35 PM, Tres Seaver <[email protected]> wrote:

>   @view_config(route='extend_views')
>   def extend_views(request):
>       config = Configurator(request.registry)
>       config.begin()
>       config.add_route(...) #etc.
>       config.commit()
>

Be aware that this is super dangerous on any "real" site as the registry is
not thread-safe. So you should, at the very least, lock it whenever you are
changing it. Thanks to the GIL you can probably assume that reading from it
is mostly safe while you're modifying it, but in general it's just a bad
idea to try to reconfigure your app after it's already running. Things like
dynamic URLs are best solved with dispatch placeholders and/or traversal
combined with a central storage mechanism. For example, envision putting
the valid URLs into redis and then asking redis if the URL is valid prior
to invoking the view (this can be easily done in a route predicate).

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to