On Mar 9, 2011, at 5:00 AM, ZHUO Qiang wrote: > Hi, > > Since I find the old pylons's way of RESTful HTTP "_method" tunnel very > handy, I have the following customize predicts to emulate the same effects in > Pyramid: > > # this predicts will using the both real HTTP method and "_method" for > prediction. And it will also convert the request.method with the "_method" if > necessary > def allowed_methods(*allowed): > def predicate(info, request): > if request.method == 'POST': > request.method = request.params.get('_method', > request.method).upper() > if request.method in allowed: > return True > return predicate > > # Here we use the predicts to define a route only for DELETE (including the > real DELETE and POST tunneled DELETE) > config.add_route('picture_delete', r'picture/{id}', > custom_predicates=(allowed_methods('DELETE'),)) > > I kindly hope some similar help function could go into Pyramid package, or at > least have a FAQ | Cookbook entry for this particular requirement
I don't know what the old tunneling method did but you can define a view only for DELETE using the request_method arg. config.add_route('picture_delete', r'picture/{id}', request_mehthod='DELETE') see http://is.gd/nq0vlm If the above is unrelated there is https://github.com/Pylons/pyramid_cookbook Cheers, ~ro -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@googlegroups.com. To unsubscribe from this group, send email to pylons-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en.