Ticket #548 (defect)
Opened 2 years ago
Last modified 2 years ago
[PATCH] Rename the before_main hook to before_handler and MainTool to HandlerTool
Status: closed (fixed)
| Reported by: | michele | Assigned to: | rdelon |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Component: | CherryPy code | Keywords: | |
| Cc: |
As discussed some times ago with fumanchu via email this little change does make much more sense IMHO and makes the hook more intuitive.
As you can see directly from the source code:
self.hooks.run('before_handler') if self.handler: self.handler() self.hooks.run('before_finalize')
I also renamed MainTool? to HandlerTool? since this is what it does, while doing this I was wondering if it could make sense to override the call method of the Tool class inside HandlerTool? to do what the handler method does now, so instead of doing this:
class Root: nav = tools.staticdir.handler(section="/nav", dir="nav", root=absDir)
you could do:
class Root: nav = tools.staticdir(section="/nav", dir="nav", root=absDir)
This is only an idea that doesn't make much sense most probably, fumanchu do you expect an HandlerTool? to be used as a decorator also? in this case it is worth keeping things as they are, I'm sure there is a good reason you made it that way that's why my patch doesn't change this aspect. ;-)
Attachments
Change History
08/18/06 14:33:44: Modified by michele
- attachment before_handler.patch added.
08/22/06 12:37:29: Modified by fumanchu
08/29/06 17:52:44: Modified by michele
Yeah, you're right indeed, there is no need to create confusion and inconsistency. ;-)
09/01/06 05:09:48: Modified by michele
This patch should probably be update to the latest revision.
I think it's worth renaming before_main to before_handler and MainTool? to HandlerTool? (since it also provides an handler method) before the first CP3 beta.
09/02/06 18:25:16: Modified by fumanchu
- status changed from new to closed.
- resolution set to fixed.
Fixed in [1325].


> fumanchu do you expect a HandlerTool? to be used > as a decorator also?
Yes. And even if I didn't, it's worth making the API uniform. ;)