lib/handler.py
author Tero Marttila <terom@fixme.fi>
Sun, 08 Feb 2009 02:55:53 +0200
branchsites
changeset 184 a3d9aa76790d
parent 172 0797aa26beaf
permissions -rw-r--r--
implement channel_view count, the query stuff, css, layout all need some cleanup :(
149
0538176eb172 YES YES MOAR WSGI - Hello World
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
"""
0538176eb172 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 :)
0538176eb172 YES YES MOAR WSGI - Hello World
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
"""
0538176eb172 YES YES MOAR WSGI - Hello World
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
172
0797aa26beaf 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: 171
diff changeset
     5
class RequestHandler (object) :
171
5ad9e9459cab route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
     6
    """
5ad9e9459cab route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
     7
        A handler handles a Request, returning a Response
5ad9e9459cab route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
     8
    """
5ad9e9459cab route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
     9
5ad9e9459cab route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    10
    def __init__ (self, func, *args, **kwargs) :
5ad9e9459cab route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    11
        self.func = func
5ad9e9459cab route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    12
        self.args = args
5ad9e9459cab route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    13
        self.kwargs = kwargs
5ad9e9459cab route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    14
    
5ad9e9459cab route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    15
    def handle_request (self, request) :
5ad9e9459cab route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    16
        """
5ad9e9459cab route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    17
            Handle the request, returning a Response object
172
0797aa26beaf 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: 171
diff changeset
    18
0797aa26beaf 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: 171
diff changeset
    19
            XXX: rename to __call__ kplzthx
171
5ad9e9459cab route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    20
        """
5ad9e9459cab route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    21
5ad9e9459cab route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    22
        return self.func(request, *self.args, **self.kwargs)
5ad9e9459cab route requests through sites/www.qmsk.net, although still hardcoded
Tero Marttila <terom@fixme.fi>
parents: 152
diff changeset
    23
150
817a8bb1cdc6 and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents: 149
diff changeset
    24