[Checkins] SVN: grok/trunk/doc/ Sample-ize 'storing data' section.

Martijn Faassen faassen at infrae.com
Sat Mar 17 11:16:09 EDT 2007


Log message for revision 73293:
  Sample-ize 'storing data' section.
  

Changed:
  A   grok/trunk/doc/groktut/storing_data/
  U   grok/trunk/doc/groktut/storing_data/src/sample/app.py
  U   grok/trunk/doc/tutorial.txt

-=-
Copied: grok/trunk/doc/groktut/storing_data (from rev 73292, grok/trunk/doc/groktut/an_empty_grok_project)

Modified: grok/trunk/doc/groktut/storing_data/src/sample/app.py
===================================================================
--- grok/trunk/doc/groktut/an_empty_grok_project/src/sample/app.py	2007-03-17 14:30:13 UTC (rev 73292)
+++ grok/trunk/doc/groktut/storing_data/src/sample/app.py	2007-03-17 15:16:09 UTC (rev 73293)
@@ -1,4 +1,13 @@
 import grok
-  
+
 class Sample(grok.Application, grok.Container):
+    text = 'default text'
+
+class Index(grok.View):
     pass
+
+class Edit(grok.View):
+    def update(self, text=None):
+        if text is None:
+            return
+        self.context.text = text

Modified: grok/trunk/doc/tutorial.txt
===================================================================
--- grok/trunk/doc/tutorial.txt	2007-03-17 14:30:13 UTC (rev 73292)
+++ grok/trunk/doc/tutorial.txt	2007-03-17 15:16:09 UTC (rev 73293)
@@ -838,22 +838,11 @@
 use one view to view the text (``index``) and another to edit it
 (``edit``).
 
-Modify ``app.py`` to read like this::
+Modify ``app.py`` to read like this:
 
-  import grok
+.. include:: groktut/storing_data/src/sample/app.py
+  :literal:
 
-  class Sample(grok.Application, grok.Container):
-      text = 'default text'
-
-  class Index(grok.View):
-      pass
-
-  class Edit(grok.View):
-      def update(self, text=None):
-          if text is None:
-             return
-          self.context.text = text
-
 The ``Sample`` class gained a class attribute with some default text.
 In the ``update`` method of the ``Edit`` view you can see we actually
 set the ``text`` attribute on the context, if at least a ``text``
@@ -861,27 +850,18 @@
 the instance of the ``Sample`` object in the object database, and thus
 will override the default ``text`` class attribute.
 
-Change the ``index.pt`` template to read like this::
+Change the ``index.pt`` template to read like this:
 
-  <html>
-  <body>
-  <p>The text: <span tal:replace="python:context.text">text</span></p>
-  </body>
-  </html>
+.. include:: groktut/storing_data/src/sample/app_templates/index.pt
+  :literal:
 
 This is a very simple template that just displays the ``text``
 attribute of the ``context`` object (our ``Sample`` instance).
 
-Create an ``edit.pt`` template with the following content::
+Create an ``edit.pt`` template with the following content:
 
-  <html>
-  <body>
-  <form tal:attributes="action view/url" method="POST">
-  Text to store: <input type="text" name="text" value="" /><br />
-  <input type="submit" value="Store" />
-  </form>
-  </body>
-  </html>
+.. include:: groktut/storing_data/src/sample/app_templates/edit.pt
+  :literal:
 
 This template display a form asking for a bit of text. It submits to
 itself.



More information about the Checkins mailing list