Re: optparse/argparse for cgi/wsgi?
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 samw...@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. -- http://mail.python.org/mailman/listinfo/python-list
Re: optparse/argparse for cgi/wsgi?
To aid your googling, the problem is also commonly called 'Dispatching' instead of 'Routing'. Joost On 14 December 2010 12:19, Joost Molenaar j.j.molen...@gmail.com wrote: 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 samw...@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. -- Joost Molenaar +31 644 015 510 -- http://mail.python.org/mailman/listinfo/python-list
optparse/argparse for cgi/wsgi?
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. -- http://mail.python.org/mailman/listinfo/python-list