Mercurial > hg > TagInTheMiddle
annotate taginthemiddle/handlers.py @ 14:86118cd8912e
display what tags we are talking about
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 05 May 2010 22:45:25 -0700 |
parents | 1ae2f98f9675 |
children | 5f492a6fbdd1 |
rev | line source |
---|---|
0
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
1 """ |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
2 request handlers: |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
3 these are instantiated for every request, then called |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
4 """ |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
5 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
6 from urlparse import urlparse |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
7 from webob import Response, exc |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 class HandlerMatchException(Exception): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
10 """the handler doesn't match the request""" |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 class Handler(object): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
13 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
14 methods = set(['GET']) # methods to listen to |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
15 handler_path = [] # path elements to match |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
16 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
17 @classmethod |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
18 def match(cls, app, request): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
19 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
20 # check the method |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
21 if request.method not in cls.methods: |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
22 return None |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
23 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
24 # check the path |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
25 if request.environ['path'][:len(cls.handler_path)] != cls.handler_path: |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
26 return None |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
27 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
28 try: |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
29 return cls(app, request) |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
30 except HandlerMatchException: |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
31 return None |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
32 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
33 def __init__(self, app, request): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
34 self.app = app |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
35 self.request = request |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
36 self.application_path = urlparse(request.application_url)[2] |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
37 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
38 def link(self, path=(), permanant=False): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
39 if isinstance(path, basestring): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
40 path = [ path ] |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
41 path = [ i.strip('/') for i in path ] |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
42 if permanant: |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
43 application_url = [ self.request.application_url ] |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
44 else: |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
45 application_url = [ self.application_path ] |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
46 path = application_url + path |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
47 return '/'.join(path) |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
48 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
49 def redirect(self, location): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
50 raise exc.HTTPSeeOther(location=location) |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
51 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
52 class GenshiHandler(Handler): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
53 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
54 def __init__(self, app, request): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
55 Handler.__init__(self, app, request) |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
56 self.data = { 'request': request, |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
57 'link': self.link } |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
58 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
59 def __call__(self): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
60 return getattr(self, self.request.method.title())() |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
61 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
62 def Get(self): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
63 # needs to have self.template set |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
64 template = self.app.loader.load(self.template) |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
65 return Response(content_type='text/html', |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
66 body=template.generate(**self.data).render('html')) |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
67 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
68 class TagCloud(GenshiHandler): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
69 template = 'cloud.html' |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
70 methods = set(['GET']) |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
71 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
72 @classmethod |
2
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
73 def match(cls, app, request): |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
74 |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
75 # check the method |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
76 if request.method not in cls.methods: |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
77 return None |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
78 |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
79 # check the path |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
80 if request.path_info.endswith('/%s' % app.tags_url): |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
81 try: |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
82 return cls(app, request) |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
83 except HandlerMatchException: |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
84 return None |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
85 |
0
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
86 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
87 class ViewTags(GenshiHandler): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
88 # TODO: RSS |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
89 template = 'tags.html' |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
90 methods = set(['GET']) |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
91 |
2
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
92 def __init__(self, app, request): |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
93 GenshiHandler.__init__(self, app, request) |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
94 path = request.path_info.split('/') |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
95 try: |
11
fc55d95be553
it is list.index, not list.find, silly!
Jeff Hammel <jhammel@mozilla.com>
parents:
2
diff
changeset
|
96 index = path.index(app.tags_url) |
2
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
97 except ValueError: |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
98 raise HandlerMatchException |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
99 self.tags = path[index+1:] |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
100 if not self.tags: |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
101 raise HandlerMatchException |
14
86118cd8912e
display what tags we are talking about
Jeff Hammel <jhammel@mozilla.com>
parents:
12
diff
changeset
|
102 self.data['tags'] = self.tags |
2
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
103 |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
104 @classmethod |
0
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
105 def match(cls, app, request): |
2
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
106 # check the method |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
107 if request.method not in cls.methods: |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
108 return None |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
109 |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
110 try: |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
111 return cls(app, request) |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
112 except HandlerMatchException: |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
113 return None |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
114 |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
115 def Get(self): |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
116 if self.request.GET.get('format') == 'rss': |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
117 pass # TODO |
1182315b18ac
add rudimentary code for handlers
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
118 return GenshiHandler.Get(self) |
0
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
119 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
120 class PostTags(Handler): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
121 methods = set(['POST']) |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
122 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
123 @classmethod |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
124 def match(cls, app, request): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
125 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
126 # check the method |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
127 if request.method not in cls.methods: |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
128 return None |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
129 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
130 # check auth |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
131 if not request.remote_user: |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
132 return None |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
133 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
134 # check the path |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
135 if request.path_info.endswith('/%s' % app.post_url): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
136 try: |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
137 return cls(app, request) |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
138 except HandlerMatchException: |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
139 return None |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
140 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
141 def __call__(self): |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
142 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
143 # get the url |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
144 url = self.request.path_info.rsplit('/' + self.app.post_url, 1)[0] |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
145 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
146 # add and remove tags |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
147 # TODO |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
148 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
149 # redirect to original resource |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
150 return exc.HTTPSeeOther(location=url) |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
151 |