Paul Johnston wrote:
> I'd like to specify a filter for a sub controller.
> If I do this using _cp_filters, it prevents the
filters
> on the parent controller being called. Is there a way
I
> can specify filters in addition?
>
> Note: I'm using CP 2.2.1 as this is a TurboGears app.
Not that I can see. I think in CP 2 you just have to share
references. :/
import cherrypy
from cherrypy.filters.basefilter import BaseFilter
class MyFilter(BaseFilter):
def before_request_body(self):
print 999, "hello!"
myfilter = MyFilter()
class MyFilter2(BaseFilter):
def before_request_body(self):
print 888, "hello!"
myfilter2 = MyFilter2()
class Entry:
_cp_filters = [ myfilter, myfilter2 ]
def view(self, id):
return 'xx'
view.exposed = True
class Root:
_cp_filters = [ myfilter ]
cherrypy.root = Root()
cherrypy.root.entries = Entry()
cherrypy.server.start()
Robert Brewer
fumanchu aminus.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|