Mercurial > p > roundup > code
comparison roundup/web/router.py @ 4906:b860ede03056 routing
routing: Add example URL map
| author | anatoly techtonik <techtonik@gmail.com> |
|---|---|
| date | Tue, 15 Jul 2014 13:42:57 +0300 |
| parents | 6e313bdf6b69 |
| children | c37069a99cec |
comparison
equal
deleted
inserted
replaced
| 4905:6e313bdf6b69 | 4906:b860ede03056 |
|---|---|
| 7 anatoly techtonik <techtonik@gmail.com> | 7 anatoly techtonik <techtonik@gmail.com> |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import re | 10 import re |
| 11 | 11 |
| 12 | |
| 13 # --- Example URL mapping | |
| 14 | |
| 15 class NamedObject(object): | |
| 16 """Object that outputs given name when printed""" | |
| 17 def __init__(self, name): | |
| 18 self.name = name | |
| 19 def __repr__(self): | |
| 20 return self.name | |
| 21 | |
| 22 ExampleHandler = NamedObject('ExampleHandler') | |
| 23 ExampleFileHandler = NamedObject('ExampleFileHandler') | |
| 24 | |
| 25 EXAMPLE_URLMAP = ( | |
| 26 '/static/(.*)', ExampleFileHandler, | |
| 27 '/', ExampleHandler | |
| 28 ) | |
| 29 | |
| 30 | |
| 31 # --- Regexp based router | |
| 12 | 32 |
| 13 class Router(object): | 33 class Router(object): |
| 14 | 34 |
| 15 def __init__(self, urlmap=[]): | 35 def __init__(self, urlmap=[]): |
| 16 """ | 36 """ |
