[Checkins] SVN: grok/trunk/doc/tutorial.txt Turn section into a sidebar.

Martijn Faassen faassen at infrae.com
Tue Feb 27 12:05:27 EST 2007


Log message for revision 72889:
  Turn section into a sidebar.
  

Changed:
  U   grok/trunk/doc/tutorial.txt

-=-
Modified: grok/trunk/doc/tutorial.txt
===================================================================
--- grok/trunk/doc/tutorial.txt	2007-02-27 17:03:36 UTC (rev 72888)
+++ grok/trunk/doc/tutorial.txt	2007-02-27 17:05:26 UTC (rev 72889)
@@ -597,6 +597,29 @@
 Completely Python-driven views
 ------------------------------
 
+.. sidebar:: Setting the content-type
+
+  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``::
+
+    import grok
+
+      class Sample(grok.Application, grok.Model):
+          pass
+
+      class Index(grok.View):
+          def render(self):
+              self.request.response.setHeader('Content-Type',
+                                              'text/xml; charset=UTF-8')
+              return "<doc>Some XML</doc>"
+
+  In Zope 3, any instance of a view has a ``request`` object
+  associated with it. This request object also has a reference to the
+  response object, which we manipulate here to set the response
+  header.
+
 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.
@@ -635,29 +658,7 @@
 looking at the content type of this page, you will see that it is
 ``text/plain``.
 
-Setting the content-type
-------------------------
 
-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``::
-
-   import grok
-
-   class Sample(grok.Application, grok.Model):
-       pass
-
-   class Index(grok.View):
-       def render(self):
-           self.request.response.setHeader('Content-Type',
-                                           'text/xml; charset=UTF-8')
-           return "<doc>Some XML</doc>"
-
-In Zope 3, any instance of a view has a ``request`` object associated
-with it. This request object also has a reference to the response
-object, which we manipulate here to set the response header.
-
 Doing some calculation before viewing a page
 --------------------------------------------
 



More information about the Checkins mailing list