I am surprise I don't find a method to extract the value of a field from a request object. At the moment I am using a helper function def getfirst(name, request): return request.args.get(name, [None])[0] but is there a better solution? Michele Simionato
Michele Simionato wrote:
I am surprise I don't find a method to extract the value of a field from a request object. At the moment I am using a helper function
def getfirst(name, request): return request.args.get(name, [None])[0]
but is there a better solution?
There is a convenience method 'arg' on nevow's context object that does this: def arg(self, get, default=None): """Placeholder until I can find Jerub's implementation of this Return a single named argument from the request arguments """ req = self.locate(IRequest) return req.args.get(get, [default])[0] It's used in nevow/examples/manualform HTH, Andy.
participants (2)
-
Andy Gayton
-
Michele Simionato