[Twisted-web] Nevow, IRequest and REST

Vincent Bernat bernat at luffy.cx
Tue Aug 21 10:34:34 EDT 2007

Hi !

In REST world, to overcome limitations of some navigators or
limitations of XHTML, there is a method called "overloaded"
POST. When you want to use PUT or DELETE method but you cannot,
you use POST and you add "_method" to POST arguments whose value
is either "PUT" or "DELETE".

I have inherited from rend.Page and used some code like this to
implement this idea:
 request = inevow.IRequest(ctx)
 if request.method == "POST" and request.args.get("_method") in ["PUT",
    request.method = request.args.get("_method")
    del request.args["_method"]

However, I now would like to use the same snippet in
rend.Fragment. I could subclass rend.Fragment but maybe there is
a better way to centralize all those modifications in one
place. Could I redefine IRequest adapter (where is it?) to
achieve this? And how to explain to the registry that my adapter
must be used in place of the original adapter?

In a similar manner, I would like to modify stan such that
T.form(method="PUT") to be turned into
T.form(method="POST")[T.input(type="hidden", name="_method",
value="PUT")]. Is it some easy way to do this ?

Thanks !

More information about the Twisted-web mailing list