Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widgets can't act as Controllers #113

Open
ghost opened this issue Jul 19, 2014 · 1 comment
Open

Widgets can't act as Controllers #113

ghost opened this issue Jul 19, 2014 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 19, 2014

tw2 widgets should be able to act as controllers
(http://tw2core.readthedocs.org/en/latest/design/#widgets-as-controllers). A
bug in tw2.core.middleware.ControllersApp does not allow to detect controller
prefix in path. Registered controllers are unreachable (http error 404).

I suspect this bug was not relevant until controller_prefix changed to '/tw2/controllers/' TurboGears/tg2@3fa1679

@ghost
Copy link
Author

ghost commented Jul 19, 2014

This patch will fix problem. It's ugly but it just works for me.

--- tw2/core/middleware.py
+++ tw2/core/middleware.py
@@ -257,6 +257,7 @@
     def __call__(self, req):
         config = rl = core.request_local()['middleware'].config
         path = req.path_info.split('/')[1:]
+        path = ['/'.join(path[:-1]), path[-1]]
         pre = config.controller_prefix.strip('/')
         if pre and path[0] != pre:
             return wo.Response(status="404 Not Found")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants