top | item 2937388

(no title)

mcdonc | 14 years ago

In a more traditional Pyramid app it would be done more like:

    from pyramid.view import view_config
    from pyramid.response import Response
    from paste.httpserver import serve
    
    @view_config(route_name='hello')
    def hello_world(request):
        return Response('Hello %(person)s' % request.matchdict)
    
    if __name__ == '__main__':
        config = Configurator()
        config.add_route('hello', '/hello/{person}')
        config.scan()
        serve(config.make_wsgi_app())
The config.scan() bit causes the @view_config decorators to be picked up. So we do have some decorators, although they don't populate an external registry (by design).

The rationale for putting the route ordering in imperative code instead of using decorator declaration order is in the document I linked. I'm not particularly interested in crippling Pyramid for larger apps to race to the bottom of the LOC count. It's succinct enough and works for truly large apps too.

discuss

order

No comments yet.