[Checkins] SVN: grok/trunk/doc/groktut/containers/ Another sample app.

Martijn Faassen faassen at infrae.com
Fri Mar 23 16:54:18 EDT 2007


Log message for revision 73491:
  Another sample app.
  

Changed:
  A   grok/trunk/doc/groktut/containers/
  U   grok/trunk/doc/groktut/containers/src/sample/app.py
  A   grok/trunk/doc/groktut/containers/src/sample/app_templates/entryindex.pt
  D   grok/trunk/doc/groktut/containers/src/sample/app_templates/index.pt
  A   grok/trunk/doc/groktut/containers/src/sample/app_templates/sampleindex.pt

-=-
Copied: grok/trunk/doc/groktut/containers (from rev 73490, grok/trunk/doc/groktut/an_empty_grok_project)

Modified: grok/trunk/doc/groktut/containers/src/sample/app.py
===================================================================
--- grok/trunk/doc/groktut/an_empty_grok_project/src/sample/app.py	2007-03-23 20:46:31 UTC (rev 73490)
+++ grok/trunk/doc/groktut/containers/src/sample/app.py	2007-03-23 20:54:17 UTC (rev 73491)
@@ -3,5 +3,19 @@
 class Sample(grok.Application, grok.Container):
     pass
 
-class Index(grok.View):
-    pass # see app_templates/index.pt
+class Entry(grok.Model):
+    def __init__(self, text):
+        self.text = text
+
+class SampleIndex(grok.View):
+    grok.context(Sample)
+    grok.name('index')
+
+    def update(self, name=None, text=None):
+        if name is None or text is None:
+            return
+        self.context[name] = Entry(text)
+
+class EntryIndex(grok.View):
+    grok.context(Entry)
+    grok.name('index')

Added: grok/trunk/doc/groktut/containers/src/sample/app_templates/entryindex.pt
===================================================================
--- grok/trunk/doc/groktut/an_empty_grok_project/src/sample/app_templates/entryindex.pt	2007-03-23 20:46:31 UTC (rev 73490)
+++ grok/trunk/doc/groktut/containers/src/sample/app_templates/entryindex.pt	2007-03-23 20:54:17 UTC (rev 73491)
@@ -0,0 +1,7 @@
+<html>
+<head>
+</head>
+<body>
+  <h2>Entry <span tal:replace="python:context.__name__"></span></h2>
+  <p tal:content="python:context.text"></p>
+</body>

Deleted: grok/trunk/doc/groktut/containers/src/sample/app_templates/index.pt
===================================================================
--- grok/trunk/doc/groktut/an_empty_grok_project/src/sample/app_templates/index.pt	2007-03-23 20:46:31 UTC (rev 73490)
+++ grok/trunk/doc/groktut/containers/src/sample/app_templates/index.pt	2007-03-23 20:54:17 UTC (rev 73491)
@@ -1,10 +0,0 @@
-<html>
-<head>
-</head>
-<body>
-  <h1>Congratulations!</h1>
-
-  <p>Your Grok application is up and running.
-  Edit <code>sample/app_templates/index.pt</code> to change
-  this page.</p>
-</body>

Added: grok/trunk/doc/groktut/containers/src/sample/app_templates/sampleindex.pt
===================================================================
--- grok/trunk/doc/groktut/an_empty_grok_project/src/sample/app_templates/sampleindex.pt	2007-03-23 20:46:31 UTC (rev 73490)
+++ grok/trunk/doc/groktut/containers/src/sample/app_templates/sampleindex.pt	2007-03-23 20:54:17 UTC (rev 73491)
@@ -0,0 +1,20 @@
+<html>
+<head>
+</head>
+<body>
+  <h2>Existing entries</h2>
+  <ul>
+    <li tal:repeat="key python:context.keys()">
+      <a tal:attributes="href python:view.url(key)" 
+         tal:content="python:key"></a>
+    </li>
+  </ul>
+ 
+  <h2>Add a new entry</h2>
+  <form tal:attributes="action python:view.url()" method="POST">
+    Name: <input type="text" name="name" value="" /><br />
+    Text: <input type="text" name="text" value="" /><br />
+    <input type="submit" value="Add entry" />
+  </form>
+
+</body>



More information about the Checkins mailing list