[Checkins] SVN: grok/trunk/doc/ More sample-izing the tutorial.

Martijn Faassen faassen at infrae.com
Fri Mar 16 17:30:16 EDT 2007


Log message for revision 73254:
  More sample-izing the tutorial.
  

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

-=-
Copied: grok/trunk/doc/groktut/setting_the_content_type (from rev 73253, grok/trunk/doc/groktut/completely_python_driven_views)

Modified: grok/trunk/doc/groktut/setting_the_content_type/src/sample/app.py
===================================================================
--- grok/trunk/doc/groktut/completely_python_driven_views/src/sample/app.py	2007-03-16 21:26:12 UTC (rev 73253)
+++ grok/trunk/doc/groktut/setting_the_content_type/src/sample/app.py	2007-03-16 21:30:15 UTC (rev 73254)
@@ -5,4 +5,7 @@
 
 class Index(grok.View):
     def render(self):
-        return "ME GROK NO TEMPLATE"
+        self.response.setHeader('Content-Type',
+                                'text/xml; charset=UTF-8')
+        return "<doc>Some XML</doc>"
+

Modified: grok/trunk/doc/tutorial.txt
===================================================================
--- grok/trunk/doc/tutorial.txt	2007-03-16 21:26:12 UTC (rev 73253)
+++ grok/trunk/doc/tutorial.txt	2007-03-16 21:30:15 UTC (rev 73254)
@@ -561,21 +561,14 @@
   When generating the complete content of a page yourself, it's often
   useful to change the content-type of the page to something else than
   ``text/plain``. Let's change our code to return simple XML and set
-  the content type to ``text/xml``::
+  the content type to ``text/xml``:
 
-    import grok
+  .. include:: groktut/setting_the_content_type/src/sample/app.py
+    :literal:
 
-      class Sample(grok.Application, grok.Container):
-          pass
+  All views in Grok have a ``response`` property that you can use to
+  manipulate response headers.
 
-      class Index(grok.View):
-          def render(self):
-              self.response.setHeader('Content-Type',
-                                      'text/xml; charset=UTF-8')
-              return "<doc>Some XML</doc>"
-
-  Views in Grok have a ``response`` object assigned to it.
-
 Sometimes it is inconvenient to have to use a template at all. Perhaps
 we are not returning a HTML page at all, for instance. In this case,
 we can use the special ``render`` method on a view.



More information about the Checkins mailing list