[Checkins] SVN: grok/trunk/grokwiki/src/grokwiki/ Use view.url()
and view.redirect() to construct URLs in an
Martijn Faassen
faassen at infrae.com
Tue Oct 31 09:54:13 EST 2006
Log message for revision 71010:
Use view.url() and view.redirect() to construct URLs in an
almost entirely uniform manner, except for the wiki-link replacing
regular expression.
Changed:
U grok/trunk/grokwiki/src/grokwiki/page.py
U grok/trunk/grokwiki/src/grokwiki/page_templates/edit.pt
U grok/trunk/grokwiki/src/grokwiki/page_templates/index.pt
U grok/trunk/grokwiki/src/grokwiki/page_templates/layout.pt
U grok/trunk/grokwiki/src/grokwiki/wiki.py
-=-
Modified: grok/trunk/grokwiki/src/grokwiki/page.py
===================================================================
--- grok/trunk/grokwiki/src/grokwiki/page.py 2006-10-31 14:40:45 UTC (rev 71009)
+++ grok/trunk/grokwiki/src/grokwiki/page.py 2006-10-31 14:54:12 UTC (rev 71010)
@@ -41,7 +41,7 @@
class Index(grok.View):
def before(self):
- wiki_url = zapi.absoluteURL(self.context.__parent__, self.request)
+ wiki_url = self.url(self.context.__parent__)
self.rendered_text, replacements = (
LINK_PATTERN.subn(r'<a href="%s/\1">\1</a>' % wiki_url,
self.context.text))
@@ -50,11 +50,9 @@
def before(self):
text = self.request.form.get('wikidata')
- self.wiki = self.context.__parent__
if not text:
- return # Just render the template
+ return # Just render the template
# Update the text and redirect
self.context.update(text)
- wiki_url = zapi.absoluteURL(self.wiki, self.request)
- self.request.response.redirect("%s/%s" % (wiki_url, self.context.__name__))
+ self.redirect(self.url(self.context))
Modified: grok/trunk/grokwiki/src/grokwiki/page_templates/edit.pt
===================================================================
--- grok/trunk/grokwiki/src/grokwiki/page_templates/edit.pt 2006-10-31 14:40:45 UTC (rev 71009)
+++ grok/trunk/grokwiki/src/grokwiki/page_templates/edit.pt 2006-10-31 14:54:12 UTC (rev 71010)
@@ -2,7 +2,7 @@
<div metal:fill-slot="content">
<h1>Edit »<span tal:replace="context/__name__">WikiPage</span>«</h1>
- <form tal:attributes="action request/URL" method="POST">
+ <form tal:attributes="action view/url" method="POST">
<textarea name="wikidata" tal:content="context/text" cols="80" rows="20"/><br/>
<input type="submit" value="Update"/>
</form>
Modified: grok/trunk/grokwiki/src/grokwiki/page_templates/index.pt
===================================================================
--- grok/trunk/grokwiki/src/grokwiki/page_templates/index.pt 2006-10-31 14:40:45 UTC (rev 71009)
+++ grok/trunk/grokwiki/src/grokwiki/page_templates/index.pt 2006-10-31 14:54:12 UTC (rev 71010)
@@ -5,6 +5,6 @@
<div tal:content="structure view/rendered_text" class="wikicontent">
</div>
- <p><a tal:attributes="href string:${context/@@absolute_url}/edit">Edit this page</a></p>
+ <p><a tal:attributes="href python:view.url('edit')">Edit this page</a></p>
</div>
</html>
Modified: grok/trunk/grokwiki/src/grokwiki/page_templates/layout.pt
===================================================================
--- grok/trunk/grokwiki/src/grokwiki/page_templates/layout.pt 2006-10-31 14:40:45 UTC (rev 71009)
+++ grok/trunk/grokwiki/src/grokwiki/page_templates/layout.pt 2006-10-31 14:54:12 UTC (rev 71010)
@@ -4,8 +4,7 @@
</head>
<body
- tal:define="wiki context/__parent__;
- wiki_url wiki/@@absolute_url">
+ tal:define="wiki context/__parent__">
<div metal:define-slot="content">
Page content goes here ...
</div>
@@ -14,7 +13,7 @@
<h3>Other pages</h3>
<p>
<span tal:repeat="page wiki">
- <a tal:attributes="href string:$wiki_url/$page"
+ <a tal:attributes="href python:view.url(wiki, page)"
tal:content="page"
/>
</span>
Modified: grok/trunk/grokwiki/src/grokwiki/wiki.py
===================================================================
--- grok/trunk/grokwiki/src/grokwiki/wiki.py 2006-10-31 14:40:45 UTC (rev 71009)
+++ grok/trunk/grokwiki/src/grokwiki/wiki.py 2006-10-31 14:54:12 UTC (rev 71010)
@@ -29,9 +29,8 @@
grok.name('index')
def render(self):
- self.request.response.redirect('home')
+ self.redirect(self.url('home'))
-
@grok.subscribe(Wiki, grok.IObjectAddedEvent)
def setupHomepage(wiki, event):
"""Creates a home page for every wiki."""
More information about the Checkins
mailing list