Mercurial > hg > lxmlmiddleware
changeset 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 | d781bdc77164 |
files | lxmlmiddleware/example.py lxmlmiddleware/middleware.py setup.py |
diffstat | 3 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/lxmlmiddleware/example.py Sun Jan 24 23:13:03 2010 -0500 +++ b/lxmlmiddleware/example.py Tue Jan 26 22:57:00 2010 -0500 @@ -7,12 +7,12 @@ return Response('<html><body>Hello, world!</body></html>')(environ, start_response) class ExampleMiddleware(LXMLMiddleware): - def manipulate(self, environ, tree): + def manipulate(self, request, response, tree): tree.append(etree.XML('<div><i>How are you doing?</i></div>')) return tree class ExampleMiddleware2(LXMLMiddleware): - def manipulate(self, environ, tree): + def manipulate(self, request, response, tree): tree.append(etree.XML("<div><b>I'm doing find, thank you!</b></div>")) return tree
--- a/lxmlmiddleware/middleware.py Sun Jan 24 23:13:03 2010 -0500 +++ b/lxmlmiddleware/middleware.py Tue Jan 26 22:57:00 2010 -0500 @@ -36,7 +36,7 @@ return response(environ, start_response) # manipulate the DOM - environ['lxml.etree'] = self.manipulate(environ, environ['lxml.etree']) + environ['lxml.etree'] = self.manipulate(request, response, environ['lxml.etree']) # recompose the DOM if the last in the chain if environ['lxml.recomposer'] is self: @@ -46,7 +46,7 @@ return response(environ, start_response) - def manipulate(self, environ, tree): + def manipulate(self, environ, response, tree): """manipulate the DOM; should return an etree._Element""" return tree