[Grok-dev] grok and urls
faassen at infrae.com
Mon Oct 30 09:13:46 EST 2006
Grok is but a simple caveman. Grok just needs a simple way to generate
URLs to things without too much thinking. We're not there yet with grok.
The current Zope 3 way to generate a URL is something like:
which is in fact zope.traversing.browser.absoluteurl's absoluteURL which
then really does a component.getMultiAdapter((ob, request), IAbsoluteURL)()
Meanwhile, grok also needs to generate various kinds of URLs. the
grokwiki has a number of places where URLs are involved:
* the redirect in wiki.py does self.request.response.redirect('home')
That's a relative URL that just happens to work. Relative URLs
unfortunately don't always happen to work.
* in page.Index there's a before method which does:
to get the URL to the wiki itself.
* in page.Edit there's another interesting
wiki_url = zapi.absoluteURL(self.wiki, self.request)
self.request.response.redirect("%s/%s" % (wiki_url,
This one is particularly horrible as it takes place in a 'before()'
method. We have a special class of URL redirects which happen
after form submits and we're sort of misusing before() here to make
* then in page_templates/edit.pt, there's a form submit to request/URL
We get the URL from the request here.
* and in page_templates/index.pt there's a tal:attributes="href
We use the absolute_url view that gets registered for lots of things,
looking it up by name. Then we tack /edit after it.
* and then in layout.pt
<a tal:attributes="href string:$wiki_url/$page"
And here we tack do some more construction, this time constructing
the name from two other names.
There appear to be about as many ways to generate URLs in this little
application as we *have* urls. ME GROK THINK NO GOOD.
In my next mail, I'll try to think through some options we got here to
make this a uniform, easily understood situation.
More information about the Grok-dev