[Checkins] SVN: Sandbox/cklinger/megrok.pagelet/trunk/src/megrok/pagelet/ Added README
Christian Klinger
cklinger at novareto.de
Mon Feb 23 08:21:55 EST 2009
Log message for revision 97159:
Added README
Changed:
A Sandbox/cklinger/megrok.pagelet/trunk/src/megrok/pagelet/README.txt
U Sandbox/cklinger/megrok.pagelet/trunk/src/megrok/pagelet/tests/test_pagelet.py
-=-
Added: Sandbox/cklinger/megrok.pagelet/trunk/src/megrok/pagelet/README.txt
===================================================================
--- Sandbox/cklinger/megrok.pagelet/trunk/src/megrok/pagelet/README.txt (rev 0)
+++ Sandbox/cklinger/megrok.pagelet/trunk/src/megrok/pagelet/README.txt 2009-02-23 13:21:55 UTC (rev 97159)
@@ -0,0 +1,60 @@
+MEGROK PAGELET
+==============
+
+This package try to grok the *template* component form z3c.template.
+z3c.template gives us a new option in layout story for grok.
+This means you have megrok.pagelet.Layout component which holds
+the layout. Instead of using grok.View you have to take megrok.pagelet.
+Pagelet for normal BrowserViews.
+
+If you need more information about z3c.template please look here [1].
+
+The Layout
+----------
+
+The first thing we have to do is set up a layout for our pagelet.
+
+class MyLayout(megrok.pagelet.Layout):
+ grok.context()
+ grok.layer()
+
+ megrok.pagelet.template('my_layout_template.pt')
+
+This configures the template ('my_layout_template.pt') as a layout for the given
+context and layer. Of course it´s possible to specify different
+layouts for different layers or contexts.
+
+
+In the content of my_layout_template.pt is something like this:
+
+<html>
+ <body>
+ <div class="layout" tal:content="structure view/render">
+ here comes the content
+ </div>
+ </body>
+</html>
+
+The Pagelt (View)
+-----------------
+
+Ok instead of using the common grok.View for our BrowserViews we use now
+megrok.pagelet.Paglet. This component has one difference to a normal
+grok.View. The difference is in the __call__ method of the megrok.pagelet.Pagelet.
+This means that the __call__ method of a Pagelet does not only return the renderd
+"template" of the Pagelet. The __call__ first search for the layout in given context
+and layer and then it renders the "template" in this layout.
+
+class View(megrok.pagelet.Pagelet)
+ grok.context()
+ grok.layer()
+ grok.name()
+
+ def render(self)
+ return "..."
+
+
+Now if you point your browser on .../view you sould see the renderd view in the
+given layout.
+
+[1] http://pypi.python.org/pypi/z3c.template/1.1.0
Modified: Sandbox/cklinger/megrok.pagelet/trunk/src/megrok/pagelet/tests/test_pagelet.py
===================================================================
--- Sandbox/cklinger/megrok.pagelet/trunk/src/megrok/pagelet/tests/test_pagelet.py 2009-02-23 13:20:01 UTC (rev 97158)
+++ Sandbox/cklinger/megrok.pagelet/trunk/src/megrok/pagelet/tests/test_pagelet.py 2009-02-23 13:21:55 UTC (rev 97159)
@@ -10,7 +10,7 @@
>>> print view()
<html>
<body>
- <div class="layout"><b> I am a MotherFucking pagelet </b></div>
+ <div class="layout"><b> I am a pagelet </b></div>
</body>
</html>
@@ -51,7 +51,7 @@
grok.context(Page)
def render(self):
- return "<b> I am a MotherFucking pagelet </b>"
+ return "<b> I am a pagelet </b>"
class PageletWithTemplate(megrok.pagelet.Pagelet):
grok.context(Page)
More information about the Checkins
mailing list