handler.py
author Tero Marttila <terom@fixme.fi>
Mon, 16 Feb 2009 19:02:59 +0200
changeset 77 bef7196f7682
parent 46 54c5f5f340de
permissions -rw-r--r--
add tree_parse test and fix treeparse to handle other than filesystem paths
7
d6a8258bd90e YES YES MOAR WSGI - Hello World
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
"""
d6a8258bd90e YES YES MOAR WSGI - Hello World
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
    The actual application behaviour, i.e. generating a Response from a Request :)
d6a8258bd90e YES YES MOAR WSGI - Hello World
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
"""
d6a8258bd90e YES YES MOAR WSGI - Hello World
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
31
107062ebb6f9 bloat code with even more layers of indirection, split off the filesystem-based stuff into a separate lib.filesystem package (next, move it to sites/www.qmsk.net)
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
     5
class RequestHandler (object) :
30
a86a25a9f75b route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
     6
    """
a86a25a9f75b route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
     7
        A handler handles a Request, returning a Response
a86a25a9f75b route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
     8
    """
a86a25a9f75b route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
     9
a86a25a9f75b route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    10
    def __init__ (self, func, *args, **kwargs) :
a86a25a9f75b route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    11
        self.func = func
a86a25a9f75b route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    12
        self.args = args
a86a25a9f75b route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    13
        self.kwargs = kwargs
a86a25a9f75b route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    14
    
a86a25a9f75b route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    15
    def handle_request (self, request) :
a86a25a9f75b route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    16
        """
a86a25a9f75b route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    17
            Handle the request, returning a Response object
31
107062ebb6f9 bloat code with even more layers of indirection, split off the filesystem-based stuff into a separate lib.filesystem package (next, move it to sites/www.qmsk.net)
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
    18
107062ebb6f9 bloat code with even more layers of indirection, split off the filesystem-based stuff into a separate lib.filesystem package (next, move it to sites/www.qmsk.net)
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
    19
            XXX: rename to __call__ kplzthx
30
a86a25a9f75b route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    20
        """
a86a25a9f75b route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    21
a86a25a9f75b route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    22
        return self.func(request, *self.args, **self.kwargs)
a86a25a9f75b route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    23
8
0ce1f471e9d7 and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents: 7
diff changeset
    24