[Checkins] SVN: z3c.viewtemplate/trunk/src/z3c/viewtemplate/
Removed the content type because it is defined in the template.
Jürgen Kartnaller
juergen at kartnaller.at
Sun Oct 15 09:45:59 EDT 2006
Log message for revision 70647:
Removed the content type because it is defined in the template.
Added more explanations to the readme file.
Changed:
U z3c.viewtemplate/trunk/src/z3c/viewtemplate/README.txt
U z3c.viewtemplate/trunk/src/z3c/viewtemplate/pagetemplate.py
-=-
Modified: z3c.viewtemplate/trunk/src/z3c/viewtemplate/README.txt
===================================================================
--- z3c.viewtemplate/trunk/src/z3c/viewtemplate/README.txt 2006-10-15 13:31:31 UTC (rev 70646)
+++ z3c.viewtemplate/trunk/src/z3c/viewtemplate/README.txt 2006-10-15 13:45:58 UTC (rev 70647)
@@ -127,7 +127,7 @@
Why didn't we use named templates from the ``zope.formlib`` package?
While named templates allow us to separate the view code from the template
-registration, they are not registerable for a particular layer making it
+registration, they are not registrable for a particular layer making it
impossible to implement multiple skins using named templates.
@@ -137,8 +137,9 @@
And for the simplest possible use we provide a RegisteredPageTemplate a la
ViewPageTemplateFile or NamedTemplate.
-The RegisteredPageTemplate allows us to use new template registration system
-with all existing implementations such as `zope.formlib` and `zope.viewlet`.
+The RegisteredPageTemplate allows us to use the new template registration
+system with all existing implementations such as `zope.formlib` and
+`zope.viewlet`.
>>> from z3c.viewtemplate.pagetemplate import RegisteredPageTemplate
>>> class IMyUseOfView(interface.Interface):
@@ -152,10 +153,19 @@
... self.context = context
... self.request = request
+By defining the "template" property as a "RegisteredPageTemplate" a lookup for
+a registered template is done when it is called. Also notice that it is no
+longer necessary to derive the view from BaseView!
+
>>> simple = UseOfRegisteredPageTemplate(root, request)
>>> print simple.template()
<div>demo</div>
+Because the demo template was registered for any ("None") interface we see the
+demo template when rendering our new view. We register a new template
+especially for the new view. Also not that the "macroTemplate" has been
+created earlier in this test.
+
>>> factory = TemplateFactory(macroTemplate, 'macro2', 'text/html')
>>> component.provideAdapter(factory,
... (IMyUseOfView, IDefaultBrowserLayer),
Modified: z3c.viewtemplate/trunk/src/z3c/viewtemplate/pagetemplate.py
===================================================================
--- z3c.viewtemplate/trunk/src/z3c/viewtemplate/pagetemplate.py 2006-10-15 13:31:31 UTC (rev 70646)
+++ z3c.viewtemplate/trunk/src/z3c/viewtemplate/pagetemplate.py 2006-10-15 13:45:58 UTC (rev 70647)
@@ -25,10 +25,6 @@
class RegisteredPageTemplate(object):
- def __init__(self, content_type=None):
- if content_type is not None:
- self.content_type = content_type
-
def __call__(self, instance):
template = component.getMultiAdapter(
(instance, instance.request), IPageTemplate)
More information about the Checkins
mailing list