'Create new request handler factory.
Use factory method to create reusable request handlers that just
require a few configuration parameters to construct.  Also useful
for injecting shared state between multiple request handler
instances without relying on global variables.  For example, to
create a set of post handlers that will do simple text transformations
you can write:
class ChangeTextHandler(webapp.RequestHandler):
def __init__(self, transform):
self.transform = transform
def post(self):
response_text = self.transform(
self.request.request.body_file.getvalue())
self.response.out.write(response_text)
application = webapp.WSGIApplication(
[(\'/to_lower\', ChangeTextHandler.new_factory(str.lower)),
(\'/to_upper\', ChangeTextHandler.new_factory(str.upper)),
debug=True)
Text POSTed to /to_lower will be lower cased.
Text POSTed to /to_upper will be upper cased.'

@classmethod
def new_factory(cls, *args, **kwargs):

    def new_instance():
        return cls(*args, **kwargs)
    new_instance.__name__ = (cls.__name__ + 'Factory')
    return new_instance
