[Checkins] SVN: grok/trunk/grokwiki/src/grokwiki/ - refactored to
make use of template directory, put models into separate files
Christian Theune
ct at gocept.com
Thu Oct 19 15:28:38 EDT 2006
Log message for revision 70819:
- refactored to make use of template directory, put models into separate files
- added sample xmlprc view (which doesn't seem to work right now)
Changed:
A grok/trunk/grokwiki/src/grokwiki/page/
A grok/trunk/grokwiki/src/grokwiki/page/edit.pt
A grok/trunk/grokwiki/src/grokwiki/page/index.pt
A grok/trunk/grokwiki/src/grokwiki/page/layout.pt
A grok/trunk/grokwiki/src/grokwiki/page.py
U grok/trunk/grokwiki/src/grokwiki/wiki.py
A grok/trunk/grokwiki/src/grokwiki/xmlrpc.py
-=-
Added: grok/trunk/grokwiki/src/grokwiki/page/edit.pt
===================================================================
--- grok/trunk/grokwiki/src/grokwiki/page/edit.pt 2006-10-19 19:27:41 UTC (rev 70818)
+++ grok/trunk/grokwiki/src/grokwiki/page/edit.pt 2006-10-19 19:28:38 UTC (rev 70819)
@@ -0,0 +1,10 @@
+<html metal:use-macro="context/@@layout/main">
+ <div metal:fill-slot="content">
+ <h1>Edit »<span tal:replace="context/__name__">WikiPage</span>«</h1>
+
+ <form tal:attributes="action request/URL" method="POST">
+ <textarea name="wikidata" tal:content="context/text" cols="80" rows="20"/><br/>
+ <input type="submit" value="Update"/>
+ </form>
+ </div>
+</html>
Property changes on: grok/trunk/grokwiki/src/grokwiki/page/edit.pt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: grok/trunk/grokwiki/src/grokwiki/page/index.pt
===================================================================
--- grok/trunk/grokwiki/src/grokwiki/page/index.pt 2006-10-19 19:27:41 UTC (rev 70818)
+++ grok/trunk/grokwiki/src/grokwiki/page/index.pt 2006-10-19 19:28:38 UTC (rev 70819)
@@ -0,0 +1,10 @@
+<html metal:use-macro="context/@@layout/main">
+ <div metal:fill-slot="content">
+ <h1 tal:content="context/__name__">WikiPage</h1>
+
+ <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>
+ </div>
+</html>
Property changes on: grok/trunk/grokwiki/src/grokwiki/page/index.pt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: grok/trunk/grokwiki/src/grokwiki/page/layout.pt
===================================================================
--- grok/trunk/grokwiki/src/grokwiki/page/layout.pt 2006-10-19 19:27:41 UTC (rev 70818)
+++ grok/trunk/grokwiki/src/grokwiki/page/layout.pt 2006-10-19 19:28:38 UTC (rev 70819)
@@ -0,0 +1,27 @@
+<html metal:define-macro="main">
+ <head>
+ <link rel="stylesheet" tal:attributes="href static/wiki.css" type="text/css">
+ </head>
+
+ <body
+ tal:define="wiki context/__parent__;
+ wiki_url wiki/@@absolute_url">
+ <div metal:define-slot="content">
+ Page content goes here ...
+ </div>
+
+ <hr/>
+ <h3>Other pages</h3>
+ <p>
+ <span tal:repeat="page wiki">
+ <a tal:attributes="href string:$wiki_url/$page"
+ tal:content="page"
+ />
+ </span>
+ </p>
+ <hr/>
+ <div id="footer">
+ This Wiki was grokked by Zope 3.
+ </div>
+ </body>
+</html>
Property changes on: grok/trunk/grokwiki/src/grokwiki/page/layout.pt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: grok/trunk/grokwiki/src/grokwiki/page.py
===================================================================
--- grok/trunk/grokwiki/src/grokwiki/page.py 2006-10-19 19:27:41 UTC (rev 70818)
+++ grok/trunk/grokwiki/src/grokwiki/page.py 2006-10-19 19:28:38 UTC (rev 70819)
@@ -0,0 +1,60 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""The grok demo wiki
+"""
+import re
+
+from zope.app import zapi
+from zope.app.folder.folder import Folder
+
+import grok
+
+
+LINK_PATTERN = re.compile('\[\[(.*?)\]\]')
+find_wiki_links = LINK_PATTERN.findall
+
+
+class WikiPage(grok.Model):
+
+ def __init__(self):
+ self.text = u"GROK EMPTY WIKI PAGE. FILL!"
+
+ def update(self, text):
+ links = find_wiki_links(text)
+ for link in links:
+ if link not in self.__parent__:
+ self.__parent__[link] = WikiPage()
+ self.text = text
+
+
+class Index(grok.View):
+
+ def before(self):
+ wiki_url = zapi.absoluteURL(self.context.__parent__, self.request)
+ self.rendered_text, replacements = (
+ LINK_PATTERN.subn(r'<a href="%s/\1">\1</a>' % wiki_url,
+ self.context.text))
+
+class Edit(grok.View):
+
+ def before(self):
+ text = self.request.form.get('wikidata')
+ self.wiki = self.context.__parent__
+ if not text:
+ 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__))
Property changes on: grok/trunk/grokwiki/src/grokwiki/page.py
___________________________________________________________________
Name: svn:keywords
+ Id Rev Date
Name: svn:eol-style
+ native
Modified: grok/trunk/grokwiki/src/grokwiki/wiki.py
===================================================================
--- grok/trunk/grokwiki/src/grokwiki/wiki.py 2006-10-19 19:27:41 UTC (rev 70818)
+++ grok/trunk/grokwiki/src/grokwiki/wiki.py 2006-10-19 19:28:38 UTC (rev 70819)
@@ -13,26 +13,19 @@
##############################################################################
"""The grok demo wiki
"""
-import re
-from zope.app import zapi
-from zope.app.folder.folder import Folder
-
import grok
+import grokwiki.page
+class Wiki(grok.Model, grok.Container):
+ """This is our wiki application wich contains all wiki pages."""
-LINK_PATTERN = re.compile('\[\[(.*?)\]\]')
-find_wiki_links = LINK_PATTERN.findall
+ @grok.traverse
+ def getWikiPage(self, name):
+ # XXX This should be the default of grok.Container
+ return self[name]
-
-# First: The wiki application
-
-class Wiki(grok.Model, Folder):
- pass
-
-
class WikiIndex(grok.View):
- grok.context(Wiki)
grok.name('index')
def render(self):
@@ -41,98 +34,7 @@
@grok.subscribe(Wiki, grok.IObjectAddedEvent)
def setupHomepage(wiki, event):
- page = WikiPage()
+ """Creates a home page for every wiki."""
+ import pdb; pdb.set_trace()
+ page = grokwiki.page.WikiPage()
wiki['home'] = page
-
-
-# Second: The wiki page
-
-class WikiPage(grok.Model):
-
- def __init__(self):
- self.text = u"GROK EMPTY WIKI PAGE. FILL!"
-
-grok.context(WikiPage)
-
-
-class Index(grok.View):
-
- def before(self):
- wiki_url = zapi.absoluteURL(self.context.__parent__, self.request)
- self.rendered_text, replacements = (
- LINK_PATTERN.subn(r'<a href="%s/\1">\1</a>' % wiki_url,
- self.context.text))
-
-
-index = grok.PageTemplate("""\
-<html metal:use-macro="context/@@layout/main">
- <div metal:fill-slot="content">
- <h1 tal:content="context/__name__">WikiPage</h1>
-
- <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>
- </div>
-</html>""")
-
-
-layout = grok.PageTemplate("""\
-<html metal:define-macro="main">
- <head>
- <link rel="stylesheet" tal:attributes="href static/wiki.css" type="text/css">
- </head>
-
- <body
- tal:define="wiki context/__parent__;
- wiki_url wiki/@@absolute_url">
- <div metal:define-slot="content">
- Page content goes here ...
- </div>
-
- <hr/>
- <h3>Other pages</h3>
- <p>
- <span tal:repeat="page wiki">
- <a tal:attributes="href string:$wiki_url/$page"
- tal:content="page"
- />
- </span>
- </p>
- <hr/>
- <div id="footer">
- This Wiki was grokked by Zope 3.
- </div>
- </body>
-</html>""")
-
-
-class Edit(grok.View):
-
- def before(self):
- text = self.request.form.get('wikidata')
- self.wiki = self.context.__parent__
- if not text:
- return # Just render the template
-
- # Update the text and redirect
- links = find_wiki_links(text)
- for link in links:
- if link not in self.wiki:
- self.wiki[link] = WikiPage()
- self.context.text = text
- wiki_url = zapi.absoluteURL(self.wiki, self.request)
- self.request.response.redirect("%s/%s" % (wiki_url, self.context.__name__))
-
-
-edit = grok.PageTemplate("""\
-<html metal:use-macro="context/@@layout/main">
- <div metal:fill-slot="content">
- <h1>Edit »<span tal:replace="context/__name__">WikiPage</span>«</h1>
-
- <form tal:attributes="action request/URL" method="POST">
- <textarea name="wikidata" tal:content="context/text" cols="80" rows="20"/><br/>
- <input type="submit" value="Update"/>
- </form>
- </div>
-</html>""")
Added: grok/trunk/grokwiki/src/grokwiki/xmlrpc.py
===================================================================
--- grok/trunk/grokwiki/src/grokwiki/xmlrpc.py 2006-10-19 19:27:41 UTC (rev 70818)
+++ grok/trunk/grokwiki/src/grokwiki/xmlrpc.py 2006-10-19 19:28:38 UTC (rev 70819)
@@ -0,0 +1,28 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""XML/RPC access to the wiki pages
+"""
+
+import grok
+import grokwiki.page
+
+
+class WikiPageRPC(grok.XMLRPC):
+ grok.context(grokwiki.page.WikiPage)
+
+ def edit(self, text):
+ self.context.update(text)
+
+ def show(self):
+ return self.context.text
Property changes on: grok/trunk/grokwiki/src/grokwiki/xmlrpc.py
___________________________________________________________________
Name: svn:keywords
+ Id Rev Date
Name: svn:eol-style
+ native
More information about the Checkins
mailing list