Ticket https://sourceforge.net/p/turbogears2/tickets/42/ made me
think that the best way to solve the issue without breaking past code
(CrudRestController manually mounted) would have been to detect where
the CrudRestController was mounted and generate all the urls from
there.
This would permit to know if the controller was mounted as octopus,
octopuss or octopi and point the requests to the mounted path instead
of forcing the user to mount it as octopuss which is wrong.
Apart from fixing the issue it would easily permit to create reusable
controllers (extensions) that are able to ask the path to reach them
to TG itself making a lot easier to create reusable components.
The counterpart is that to implement this I found an issue in how
DispatchState works.
Currently DispatchState.controller_path is a dictionary where the key
is the path part and the value is the controller associated to that
part.
For example if we are dispatching /sub/nested we would have
{'sub':SubController, 'nested':NestedController}
This has the issue of totally getting messed up if you have parts of
the url which share the name.
For example a /sub/nested/sub url would result in
{'sub':SecondSubController, 'nested':NestedController} totally
forgetting about the original SubController.
To solve this I had to change controller_path to a list instead of a dictionary.
All the test units still pass, but I would like to know if anyone has
ever used request.controller_state.controller_path for any purpose
because my change would break their code.
I expect it to be a private implementation details, so it should be
fairly save to change it.
The two new features it would introduce are:
- TGController.mount_point property -> static mount point of a controller
- tg.dispatched_controller() -> a reference to the last controller
that dispatched the request, it always return a controller that has a
valid mount_point. If the request is managed using _lookup the
returned controller is the one that implemented the _lookup method.
--
You received this message because you are subscribed to the Google Groups
"TurboGears Trunk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears-trunk?hl=en.