Having a context registry object where I could fetch the current request could remove all of repeated code that is just used to wire a request object into a method.
Does that context object exist for the scala version of the framework?
If not, can there be plans added to include it in a subsequent release?
[…]
> Does that context object exist for the scala version of the framework?
No.
> If not, can there be plans added to include it in a subsequent release?
No, because thanks to implicit parameters this context object can be
avoided in Scala.
Just make your productHeader method take an implicit Request and you’re done.
You may also be interested in reading this:
http://stackoverflow.com/questions/9629250/how-to-avoid-passing-parameters-everywhere-in-play2/9632085#9632085
I don’t know Guillaume’s or Sadek’s point of view, but IMHO it’s
better to declare every function dependencies in its parameters
instead of letting it access global variables. It makes the code
easier to reason about and less fragile because its dependencies are
more visible.
Then for each page that uses the public.scala.html view, I had to start dragging around the implicit request in the view signature...
login.scala.html
@(implicit request:Request[AnyContent])
@public {
<p>Login html stuffs</p>
}
When using the implicit argument, the only benefit is that I don't have to specify @public(request) { ... } in login.scala.html, and in public.scala.html, I don't have to specify @controller.produceHeader(request). Since you still have to include the implicit argument to each view, there's really no savings.
So if it worked like you suggested and the only code i had to add was an implicit argument for the request on the method and didn't have to modify the signatures of any of the view field, then yes, epic win!
I see...
But the idea is also to see the session after the action... you can see the request/response on browser side but I'm more interested in the data on server side!
Pascal
On Sun, Apr 22, 2012 at 1:57 PM, Julien Richard-Foy wrote:
I’m not Guillaume but here’s how I would handle this case: I would
have a state only for my development plugin. This state would be set
for each request using the Global#onRouteRequest hook. It would *not*
allow to see response headers though.
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-framework@googlegroups.com.
To unsubscribe from this group, send email to play-framework+unsubscribe@googlegroups.com.
But you can’t guarantee there always is a Request. For instance you
could use the template engine from a background job.
I see...
But the idea is also to see the session after the action... you can see the request/response on browser side but I'm more interested in the data on server side!
Pascal
On Sun, Apr 22, 2012 at 1:57 PM, Julien Richard-Foy <j...@zenexity.com> wrote:
I’m not Guillaume but here’s how I would handle this case: I would
have a state only for my development plugin. This state would be set
for each request using the Global#onRouteRequest hook. It would *not*
allow to see response headers though.
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-framework@googlegroups.com.
To unsubscribe from this group, send email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/NmYtRmjlFogJ.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.