[Zope3-checkins]
SVN: Zope3/branches/roger-contentprovider/src/zope/contentprovider/
first steps towards making the tests run again
Helmut Merz
helmutm at cy55.de
Thu Oct 6 14:06:45 EDT 2005
Log message for revision 38816:
first steps towards making the tests run again
Changed:
U Zope3/branches/roger-contentprovider/src/zope/contentprovider/README.txt
U Zope3/branches/roger-contentprovider/src/zope/contentprovider/tales.py
-=-
Modified: Zope3/branches/roger-contentprovider/src/zope/contentprovider/README.txt
===================================================================
--- Zope3/branches/roger-contentprovider/src/zope/contentprovider/README.txt 2005-10-06 17:58:30 UTC (rev 38815)
+++ Zope3/branches/roger-contentprovider/src/zope/contentprovider/README.txt 2005-10-06 18:06:45 UTC (rev 38816)
@@ -55,7 +55,7 @@
>>> class Viewlet(object):
... def __init__(self, *args): pass
... title = 'Demo Viewlet'
- ... weight = 1
+ ... weight = 5
... def __call__(self, *args, **kw):
... return 'viewlet content'
@@ -148,25 +148,13 @@
</html>
-Class-driven Viewlets
-~~~~~~~~~~~~~~~~~~~~~
+ >>> class InfoViewlet(object):
+ ... def __init__(self, *args): pass
+ ... title = 'Info Viewlet'
+ ... weight = 3
+ ... def __call__(self, *args, **kw):
+ ... return 'viewlet information'
-Let's now have a look into the steps involved to create a viewlet class from
-scratch. We also want to ensure that this viewlet always displays second and
-not before the first one. Here is a most simple implementation:
-
- >>> from zope.app.publisher.browser import BrowserView
- >>> class InfoViewlet(BrowserView):
- ... zope.interface.implements(interfaces.IViewlet, ILeftColumn)
- ... weight = 1
- ...
- ... def __init__(self, context, request, view):
- ... super(InfoViewlet, self).__init__(context, request)
- ... self.view = view
- ...
- ... def __call__(self):
- ... return u'<h3>Some Information.</h3>'
-
>>> defineChecker(InfoViewlet, viewletChecker)
>>> zope.component.provideAdapter(
@@ -175,13 +163,6 @@
... ILeftColumn,
... name='infoViewlet')
-
-
-
-Note that you would commonly not state in the class itself that it
-implements a particular region, since it is usually done by the ZCML
-directive, which is introduced in `directives.zcml`.
-
When we now render the view, the content of our info viewlet appears as well:
>>> print view().strip()
@@ -190,14 +171,9 @@
<h1>My Web Page</h1>
<div class="left-column">
<div class="column-item">
- <BLANKLINE>
- <div class="box">
- Viewlet Title
- </div>
- <BLANKLINE>
- </div>
+ viewlet information
<div class="column-item">
- <h3>Some Information.</h3>
+ viewlet content
</div>
</div>
<div class="main">
Modified: Zope3/branches/roger-contentprovider/src/zope/contentprovider/tales.py
===================================================================
--- Zope3/branches/roger-contentprovider/src/zope/contentprovider/tales.py 2005-10-06 17:58:30 UTC (rev 38815)
+++ Zope3/branches/roger-contentprovider/src/zope/contentprovider/tales.py 2005-10-06 18:06:45 UTC (rev 38816)
@@ -99,16 +99,16 @@
region = getRegion(self._iface)
# Find the viewlets
- viewletManager = zope.component.queryMultiAdapter(
- (context, request, view), interfaces.IViewletManager)
- if viewletManager is None:
- viewletManager = manager.DefaultViewletManager(
+ cpManager = zope.component.queryMultiAdapter(
+ (context, request, view), interfaces.IContentProviderManager)
+ if cpManager is None:
+ cpManager = manager.DefaultContentProviderManager(
context, request, view)
- viewlet = viewletManager.getViewlet(self._name, region)
+ provider = cpManager.__getitem__(self._name, region)
# Insert the data gotten from the context
data = getRegionFieldData(region, econtext)
- viewlet.__dict__.update(data)
+ provider.__dict__.update(data)
- return viewlet()
+ return provider()
More information about the Zope3-Checkins
mailing list