Issue #548 resolved

[PATCH] Rename the before_main hook to before_handler and MainTool to HandlerTool

michele avatarmichele created an issue

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. ;-)

Comments (5)

  1. 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.

  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.