-
Notifications
You must be signed in to change notification settings - Fork 11
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
Make "play.mvc.Controller".setContext implementable #223
Conversation
Signed-off-by: cies <[email protected]>
e8da986
to
59c4fb9
Compare
Now with the tests passing... |
@cies do we really need new interface |
Good question. It's because of this bit of code: I read it meaning "you can have a basic controller without the context being set by the FW, or you can have a rich controller with the context set". I did not want to change behaviour of the FW, so I wanted to keep the basic controller available for whomever may have written code depending on that. We do not need the basic one (and with a self implementation setContext() method we can make a basic controller ourselves. So I wont mind simplifying it. TL;DR. I tried to keep the API stable "for others". |
I can adjust (or feel free to adjust) it. All I want to achieve is more control over what context i'm giving certain controller superclasses as the built-in-RePlay validation, renderArgs and flash is on their way out for us, hence I like not to expose them. Also I want to be able to choose the visibility (public/protected/private) of the controller's request/response/session fields, as we simply pass the controller to the view. |
Really? You the whole controller instance to the view? Why? P.S. Let me double-check. Do I correctly understand that you don't like |
Yes for various reasons. We want to build links in the views, and for that we needs request/response since RePlay deprecated the thread local solution. We also generate links based on ref ( I've accepted that the controller and view are not as well decoupled as model is in the MVC split.
Yes, as per this bit of code only And I'd like to be able to implement it myself. |
So we ended up in fixed routes as plain text. It doesn't really create a big work for us, but it's stable and predictable. Anyway, I don't understand why do you need to set some context to controller to be able to modify dynamic links? The links should not depend on any context.
|
We forbid
Those are two separate concerns. I want to be able to set the context myself (AND implement Controller myself) for these reasons:
I know about ideals, but there's the reality of this working great. Controller action method refs are the way we build links (not based on the horrendously hard to refactor Play1ism strings Myself, I do not worry to much about V and C coupling (I do care about M decoupling); since they are more closely related: they are totally useless without each other anyway. If #256 lands in a release we are not so much reliant on request/response in our views in order to build links with non-deprecated methods. If was because we needed request+response from the controller anyway that we started passing the whole controller along, as we put methods to build link on controller super-classes since the controller has the request+response object. |
We currently inherit from
Controller
. I want to remove some of it's capabilities in some cases (say in case of controllers that are only concerned with API requests). And I want to add some capabilities in other cases.So I added the PlayContextController interface in between Controller and PlayController which defines the setContext() method, so ActionInvoker will be able to add the context to the controller I implement.