[Checkins] SVN: grok/trunk/doc/ A view for a model sample-appize phase 1.

Martijn Faassen faassen at infrae.com
Sat Mar 17 06:58:27 EDT 2007


Log message for revision 73280:
  A view for a model sample-appize phase 1.
  

Changed:
  A   grok/trunk/doc/groktut/a_view_for_a_model/
  U   grok/trunk/doc/groktut/a_view_for_a_model/src/sample/app.py
  U   grok/trunk/doc/groktut/a_view_for_a_model/src/sample/app_templates/index.pt
  U   grok/trunk/doc/tutorial.txt

-=-
Copied: grok/trunk/doc/groktut/a_view_for_a_model (from rev 73246, grok/trunk/doc/groktut/publishing_a_simple_web_page)

Modified: grok/trunk/doc/groktut/a_view_for_a_model/src/sample/app.py
===================================================================
--- grok/trunk/doc/groktut/publishing_a_simple_web_page/src/sample/app.py	2007-03-16 20:51:35 UTC (rev 73246)
+++ grok/trunk/doc/groktut/a_view_for_a_model/src/sample/app.py	2007-03-17 10:58:26 UTC (rev 73280)
@@ -1,7 +1,8 @@
 import grok
-  
+
 class Sample(grok.Application, grok.Container):
-    pass
+    def information(self):
+        return "This is important information!"
 
 class Index(grok.View):
     pass

Modified: grok/trunk/doc/groktut/a_view_for_a_model/src/sample/app_templates/index.pt
===================================================================
--- grok/trunk/doc/groktut/publishing_a_simple_web_page/src/sample/app_templates/index.pt	2007-03-16 20:51:35 UTC (rev 73246)
+++ grok/trunk/doc/groktut/a_view_for_a_model/src/sample/app_templates/index.pt	2007-03-17 10:58:26 UTC (rev 73280)
@@ -1,5 +1,5 @@
 <html>
 <body>
-<p>Hello world!</p>
+<p tal:content="python:context.information()">replaced</p>
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: grok/trunk/doc/tutorial.txt
===================================================================
--- grok/trunk/doc/tutorial.txt	2007-03-17 10:51:44 UTC (rev 73279)
+++ grok/trunk/doc/tutorial.txt	2007-03-17 10:58:26 UTC (rev 73280)
@@ -741,33 +741,25 @@
 In typical applications this is not the case however - views display
 information that is stored elsewhere. In Grok applications, views work
 for content objects; subclasses of ``grok.Model`` or
-``grok.Container``. A ``grok.Container`` is a special kind of
-``grok.Model``, more about this later.
+``grok.Container``. For the purposes of this discussion, we can treat
+a ``grok.Container`` as another kind of ``grok.Model`` (more about
+what makes ``grok.Container`` special later XXX).
 
-Our ``Sample`` class is a ``grok.Container``, so let's use this to
-demonstrate the basic principle. Let's modify ``app.py`` so that
-``Sample`` actually makes some data available::
+Our ``Sample`` class is a ``grok.Container``, so let's use ``Sample``
+to demonstrate the basic principle. Let's modify ``app.py`` so that
+``Sample`` actually makes some data available:
 
-  import grok
+.. include:: groktut/a_view_for_a_model/src/sample/app.py
+  :literal:
 
-  class Sample(grok.Application, grok.Container):
-      def information(self):
-          return "This is important information!"
-
-  class Index(grok.View):
-      pass
-
 In this case, the information (``"This is important information!"``)
 is just hardcoded, but you can imagine information is retrieved from
 somewhere else, such as a relational database or the filesystem.
 
-We now want to display this information in our template ``index.pt``::
+We now want to display this information in our template ``index.pt``:
 
-  <html>
-  <body>
-  <p tal:content="python:context.information()">replaced</p>
-  </body>
-  </html>
+.. include:: groktut/a_view_for_a_model/src/sample/app_templates/index.pt
+  :literal:
 
 Restart Zope. When you view the page:
 



More information about the Checkins mailing list