Gentlenoob,
You can be confident that Pyramid will not run code that you don't need and
have not configured. I would write your example a bit like the following.
Pyramid makes the matched parameters from the route available in
request.matchdict and the presumably json request body as request.body; you
get to call simplejson.loads(request.body) and int(request.matchdict['foo'])
yourself. The 'json' renderer serializes the return value to json for you.
Some people prefer to send all requests for a particular route to a
class-based view that can delegate the different request methods to its own
methods, but I just like using functions and view predicates such as
request_method. The following doesn't seem too far away from what I know
about sinatra from reading its landing page.
@view_config(route_name='routeA', renderer='json', request_method='POST')
def handle_POST(request):
return {'post':'posted'}
@view_config(route_name='routeA', renderer='json', request_method='POST')
def handle_GET(request):
return {'get':'got'}
... later, in the 'create WSGI app' function:
config.add_route('routeA', '/{foo:\d+}/routeA/routeA.json')
config.scan()
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.