[Grok-dev] grok.url() requiring a request object a bit inconvenient
janwijbrand at gmail.com
Sun Nov 1 09:03:52 EST 2009
Sebastian Ware wrote:
> I find it a bit inconvenient that you have to supply a request object
> with the grok.url() method. If I want to create an url during an event
> to for example send an email, it would be great if I could call...
> ....without having to supply a request object.
> Mvh Sebastian
-1 for not having to pass a request object to the grok.url() helper
As said in this thread: the request contain crucial information about
how to compute the URL.
+1 for a convenience function to get to the current request object in a
Even though the ZTK does not really promote retrieving the request
object "yourself" (and I think rightfully so!) there are situations
where you really really want to be able to get the request anyway.
Having such a convenience method makes calling grok.url() somewhat easier..:
...but still we maintain grok.url()'s explicitness and testability.
There're a couple of packages out there that do get to the "global"
request. We should look that these packages for inspiration when
implementing grok.global_request(). On the top of my head there is:
* hurry.resource (or is it hurry.zope.resource)
There're probably more..
Having said this, I have to remark that I only rarely need to get to the
request "myself". To me it seems most often, with the right factoring,
the request is just there in the view-like components.
More information about the Grok-dev