Originally reported by: coady (Bitbucket: coady, GitHub: coady)
For simple function tools, they're almost always registered immediately after defining them, using the same name. Even the example in the docs:
#!python
def protect(users):
if cherrypy.request.login not in users:
raise cherrypy.HTTPError("401 Unauthorized")
cherrypy.tools.protect = Tool('on_start_resource', protect)
This pattern seems like a perfect use case for a decorator. Such as:
#!python
@cherrypy.tools.register('on_start_resource')
def protect(users):
if cherrypy.request.login not in users:
raise cherrypy.HTTPError("401 Unauthorized")
Originally reported by: coady (Bitbucket: coady, GitHub: coady)
For simple function tools, they're almost always registered immediately after defining them, using the same name. Even the example in the docs:
This pattern seems like a perfect use case for a decorator. Such as:
The text was updated successfully, but these errors were encountered: