News for hackers. Stuff that matters.
Re:Python web micro-framework battle by mmerickel on Monday August 29, 2011 @12:23PM (#2937699)
The ordering of your patterns matters, so that is done at config time. However it's very common to want to have unrelated code executed depending on the type of request to a URL. Pyramid will do this lookup for you, rather than polluting a gigantic view function with multiple code-paths for distinct functionality.

    @view_config(route_name='hello', request_method='GET')
    def get_hello(request):
        return Response('a GET request for %s' % request.matchdict['name'])

    @view_config(route_name='hello', request_method='POST')
    def post_hello(request):
        return Response('stored info')

    config = Configurator()
    config.add_route('hello', '/hello/{name}')
    config.scan()
    app = config.make_wsgi_app()
Re:Python web micro-framework battle by mcdonc on Monday August 29, 2011 @12:44PM (#2937793)
Bottle and Flask actually allow for this too. Bottle's variant:

   @route('/hello/:name', method='GET')
   def hello_get(name):
       return 'Hello %s' % name

   @route('/hello/:name', method='POST')
   def hello_post(name):
       return 'Hello %s' % name
Pyramid permits a larger variety of predicates (including custom ones), however: https://docs.pylonsproject.org/projects/pyramid/1.2/narr/vie...
Re:Python web micro-framework battle by mmerickel on Monday August 29, 2011 @01:33PM (#2938007)
Yes but while implicit route ordering works a lot of the time, I'll gladly keep Pyramid's concept of explicit ordering, which is the main source of verbosity in the Pyramid setup which separates routes from views.
Re:Python web micro-framework battle by mcdonc on Monday August 29, 2011 @05:49PM (#2939191)
The order the decorators are run at import time is explicit. Everybody loves module-scope programming and import-time side-effects! What's wrong with you man? ;-)