author | Tero Marttila <terom@fixme.fi> |
Mon, 16 Feb 2009 22:40:35 +0200 | |
changeset 86 | 6ff1140586d6 |
parent 46 | 54c5f5f340de |
permissions | -rw-r--r-- |
7 | 1 |
""" |
2 |
The actual application behaviour, i.e. generating a Response from a Request :) |
|
3 |
""" |
|
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 |