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

--
http://zhuoqiang.me

-- 
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.

Reply via email to