[Checkins] SVN: Sandbox/ulif/megrok.chameleon/src/megrok/chameleon/README.txt Add more tests.

Uli Fouquet uli at gnufix.de
Sun Feb 22 07:44:47 EST 2009


Log message for revision 97029:
  Add more tests.

Changed:
  U   Sandbox/ulif/megrok.chameleon/src/megrok/chameleon/README.txt

-=-
Modified: Sandbox/ulif/megrok.chameleon/src/megrok/chameleon/README.txt
===================================================================
--- Sandbox/ulif/megrok.chameleon/src/megrok/chameleon/README.txt	2009-02-22 12:44:27 UTC (rev 97028)
+++ Sandbox/ulif/megrok.chameleon/src/megrok/chameleon/README.txt	2009-02-22 12:44:47 UTC (rev 97029)
@@ -52,8 +52,9 @@
     >>> grok.testing.grok('megrok.chameleon')
     >>> grok.testing.grok('megrok.chameleon.tests.cpt_fixture')
 
-We create a mammoth, which should provide us a bunch of Genshi driven
-views and put it in the database to setup location info::
+We create a mammoth, which should provide us a bunch of chameleon page
+template driven views and put it in the database to setup location
+info::
 
     >>> from megrok.chameleon.tests.cpt_fixture.app import Mammoth
     >>> manfred = Mammoth()
@@ -65,6 +66,61 @@
     >>> from zope.component import getMultiAdapter
     >>> request = TestRequest()
 
+Simple templates
+----------------
+
+We prepared a plain cavepainting view. The template looks like this::
+
+    >>> cavepainting_cpt = os.path.join(template_dir, 'cavepainting.cpt')
+    >>> print open(cavepainting_cpt, 'rb').read()
+    <html>
+      <body>
+        A cave painting.
+      </body>
+    </html>
+
+The rendered view looks like this::
+
+    >>> view = getMultiAdapter((manfred, request),
+    ...                         name='cavepainting')
+    >>> print view()
+    <html>
+      <body>
+        A cave painting.
+      </body>
+    </html>
+
+Substituting variables
+----------------------
+
+A template can access variables like ``view``, ``context`` and its
+methods and attributes. The ``food`` view does exactly this. The
+template looks like this::
+
+    >>> food_cpt = os.path.join(template_dir, 'food.cpt')
+    >>> print open(food_cpt, 'rb').read()
+    <html>
+    <body>
+    ${view.me_do()}
+    CSS-URL: ${static['test.css']()}
+    My context is: ${view.url(context)}
+    </body>
+    </html>
+
+The rendered view looks like this::
+
+    >>> view = getMultiAdapter((manfred, request), name='food')
+    >>> print view()
+    <html>
+    <body>
+    ME GROK EAT MAMMOTH!
+    CSS-URL: http://127.0.0.1/@@/megrok.chameleon.tests.cpt_fixture/test.css
+    My context is: http://127.0.0.1/manfred
+    </body>
+    </html>
+
+
+
 Clean up::
 
     >>> del getRootFolder()['manfred']



More information about the Checkins mailing list