[Checkins] SVN: megrok.chameleon/branches/ulif-chameleon_2-support/src/megrok/chameleon/README.txt - In tests do not expect the `static` variable to work any longer.
Uli Fouquet
uli at gnufix.de
Mon Apr 11 09:31:46 EDT 2011
Log message for revision 121379:
- In tests do not expect the `static` variable to work any longer.
- Do not test (removed) Genshi templates any more.
Changed:
U megrok.chameleon/branches/ulif-chameleon_2-support/src/megrok/chameleon/README.txt
-=-
Modified: megrok.chameleon/branches/ulif-chameleon_2-support/src/megrok/chameleon/README.txt
===================================================================
--- megrok.chameleon/branches/ulif-chameleon_2-support/src/megrok/chameleon/README.txt 2011-04-11 13:30:04 UTC (rev 121378)
+++ megrok.chameleon/branches/ulif-chameleon_2-support/src/megrok/chameleon/README.txt 2011-04-11 13:31:45 UTC (rev 121379)
@@ -104,7 +104,6 @@
<span tal:define="foo 'a FOO'">
${view.me_do()}
<span tal:replace="structure view.me_do()" />
- CSS-URL: ${static['test.css']()}
My context is: ${view.url(context)}
${foo}
<span tal:replace="foo" />
@@ -121,7 +120,6 @@
<span>
<ME GROK EAT MAMMOTH!>
<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
a FOO
a FOO
@@ -169,9 +167,6 @@
* ``request``
the current request
-* ``static``
- the static dir of the application
-
as we can see, when we look at the ``vars.cpt`` from our fixture:
>>> cpt_file = os.path.join(template_dir, 'vars.cpt')
@@ -191,9 +186,6 @@
<BLANKLINE>
request (the current request):
${request}
- <BLANKLINE>
- static (the static dir of the application):
- ${static}
</body>
</html>
@@ -206,7 +198,7 @@
This template knows about the following vars:
<BLANKLINE>
template (the template instance):
- <vars template in ...vars.cpt>
+ <PageTemplateFile ...vars.cpt>
<BLANKLINE>
view (the associated view):
<megrok.chameleon.tests.cpt_fixture.app.Vars object at 0x...>
@@ -219,9 +211,6 @@
GATEWAY_INTERFACE: TestFooInterface/1.0
HTTP_HOST: 127.0.0.1
SERVER_URL: http://127.0.0.1
- <BLANKLINE>
- static (the static dir of the application):
- <grokcore.view.components.DirectoryResource object at 0x...>
</body>
</html>
@@ -350,8 +339,8 @@
</div>
<BLANKLINE>
<!-- We support `not` -->
- <div>False</div>
- <div>False</div>
+ <div></div>
+ <div></div>
<div>True</div>
<div>True</div>
<BLANKLINE>
@@ -466,161 +455,3 @@
``tal:content="view.value"``. Every occurence of TAL-expressions
starting with ``python:`` now can be shortened by skipping this
marker.
-
-Chameleon Genshi templates
-==========================
-
-Chameleon provides support for Genshi templates which can be used from
-grok writing templates with the ``.cg`` filename extension.
-
-Genshi text templates can be used with the ``.cgt`` filename
-extension.
-
-Note, that chameleon genshi templates might not cover the full range
-of functionality offered by native genshi parsers. Use `megrok.genshi`
-if you want native genshi support.
-
-See the `chameleon.genshi`_ page for more information.
-
-.. _chameleon.genshi: http://pypi.python.org/pypi/chameleon.genshi
-
-
-Prerequisites
--------------
-
-Before we can see the templates in action, we care for correct
-registration and set some used variables:
-
- >>> import os
- >>> testdir = os.path.join(os.path.dirname(__file__), 'tests')
- >>> genshi_fixture = os.path.join(testdir, 'genshi_fixture')
- >>> template_dir = os.path.join(genshi_fixture, 'app_templates')
-
-We register everything. Before we can grok our fixture, we have to
-grok the `megrok.chameleon` package. This way the new template types
-are registered with the framework:
-
- >>> grokcore.view.testing.grok('megrok.chameleon')
- >>> grokcore.view.testing.grok('megrok.chameleon.tests.genshi_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:
-
- >>> from megrok.chameleon.tests.genshi_fixture.app import Mammoth
- >>> manfred = Mammoth()
- >>> getRootFolder()['manfred'] = manfred
-
-Furthermore we prepare for getting the different views on manfred:
-
- >>> from zope.publisher.browser import TestRequest
- >>> from zope.component import getMultiAdapter
- >>> request = TestRequest()
-
-
-Simple templates
-----------------
-
-We prepared a plain cavepainting view. The template looks like this:
-
- >>> cavepainting_cg = os.path.join(template_dir, 'cavepainting.cg')
- >>> print open(cavepainting_cg, '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_cg = os.path.join(template_dir, 'food.cg')
- >>> print open(food_cg, '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.genshi_fixture/test.css
- My context is: http://127.0.0.1/manfred
- </body>
- </html>
-
-
-Including other templates
--------------------------
-
-With genshi support we can also include other templates. The
-``gatherer`` view looks like this:
-
- >>> gatherer_cg = os.path.join(template_dir, 'gatherer.cg')
- >>> print open(gatherer_cg, 'rb').read()
- <html xmlns:xi="http://www.w3.org/2001/XInclude">
- <body>
- ME GROK GATHER BERRIES!
- <xi:include href="berries.cg"/>
- </body>
- </html>
-
-Apparently here we include a template called ``berries.cg``. It looks
-like this:
-
- >>> berries_cg = os.path.join(template_dir, 'berries.cg')
- >>> print open(berries_cg, 'rb').read()
- <strong>Lovely blueberries!</strong>
-
-
-When we render the former template, we get:
-
- >>> view = getMultiAdapter((manfred, request), name='gatherer')
- >>> print view()
- <html>
- <body>
- ME GROK GATHER BERRIES!
- <strong>Lovely blueberries!</strong>
- </body>
- </html>
-
-Text templates
---------------
-
-Also genshi text templates are supported. We have a template that
-looks like so:
-
- >>> hunter_cgt = os.path.join(template_dir, 'hunter.cgt')
- >>> print open(hunter_cgt, 'rb').read()
- ME GROK HUNT ${view.game}!
-
-Note, that this template has the ``.cgt`` (= **c**\ ameleon **g**\ enshi
-**t**\ ext template) file extension.
-
-If we render it, all expressions are substituted:
-
- >>> view = getMultiAdapter((manfred, request), name='hunter')
- >>> print view()
- ME GROK HUNT MAMMOTH!!
More information about the checkins
mailing list