Mercurial > hg > lxmlmiddleware
comparison lxmlmiddleware/middleware.py @ 3:ca1f58f5bad4
pass a webob request and response to the manipulate method, API change, bumping version
author | k0s <k0scist@gmail.com> |
---|---|
date | Tue, 26 Jan 2010 22:57:00 -0500 |
parents | bb7d50d54cb6 |
children |
comparison
equal
deleted
inserted
replaced
2:bb7d50d54cb6 | 3:ca1f58f5bad4 |
---|---|
34 except etree.XMLSyntaxError: # not XML | 34 except etree.XMLSyntaxError: # not XML |
35 environ.pop('lxml.recomposer') | 35 environ.pop('lxml.recomposer') |
36 return response(environ, start_response) | 36 return response(environ, start_response) |
37 | 37 |
38 # manipulate the DOM | 38 # manipulate the DOM |
39 environ['lxml.etree'] = self.manipulate(environ, environ['lxml.etree']) | 39 environ['lxml.etree'] = self.manipulate(request, response, environ['lxml.etree']) |
40 | 40 |
41 # recompose the DOM if the last in the chain | 41 # recompose the DOM if the last in the chain |
42 if environ['lxml.recomposer'] is self: | 42 if environ['lxml.recomposer'] is self: |
43 response.body = lxml.html.tostring(environ['lxml.etree']) | 43 response.body = lxml.html.tostring(environ['lxml.etree']) |
44 | 44 |
45 # return the response | 45 # return the response |
46 return response(environ, start_response) | 46 return response(environ, start_response) |
47 | 47 |
48 | 48 |
49 def manipulate(self, environ, tree): | 49 def manipulate(self, environ, response, tree): |
50 """manipulate the DOM; should return an etree._Element""" | 50 """manipulate the DOM; should return an etree._Element""" |
51 return tree | 51 return tree |
52 | 52 |