optparse/argparse for cgi/wsgi?

Joost Molenaar j.j.molenaar at gmail.com
Tue Dec 14 06:19:12 EST 2010


Many people have. :-)

In the context of WSGI you're basically talking about routing
middleware, which solves the problem: "given a request, which
application should be called to construct a response?"

In my case, it turned out as simple as a list of (regex, resource)
tuples, where regex is a regular expression that looks at the
request URI and resource is an object that may or may not
implement GET, POST, PUT, DELETE methods. In the regex
I can capture any arguments that the resource needs. If the
request method is GET and the method GET exists on the
matched resource, it is called, else a 'Method Not Allowed'
response code is returned.

HTH

Joost

On 10 December 2010 17:36, samwyse <samwyse at gmail.com> wrote:

> Has anyone ever built some sort of optparse/argparse module for cgi/
> wsgi programs?  I can see why a straight port wouldn't work, but a
> module that can organize parameter handling for web pages seems like a
> good idea, especially if it provided a standard collection of both
> client- and server-side validation processes, easy
> internationalization, and a way to create customizable help pages.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101214/acb70238/attachment-0001.html>


More information about the Python-list mailing list