[Checkins]
SVN: Zope3/branches/acripps-new_Viewlet_Directive/src/zope/viewlet/meta
Added the resourceViewlet directive
Aaron Cripps
acripps at gmail.com
Wed May 30 09:41:16 EDT 2007
Log message for revision 75998:
Added the resourceViewlet directive
Changed:
U Zope3/branches/acripps-new_Viewlet_Directive/src/zope/viewlet/meta.zcml
U Zope3/branches/acripps-new_Viewlet_Directive/src/zope/viewlet/metaconfigure.py
U Zope3/branches/acripps-new_Viewlet_Directive/src/zope/viewlet/metadirectives.py
-=-
Modified: Zope3/branches/acripps-new_Viewlet_Directive/src/zope/viewlet/meta.zcml
===================================================================
--- Zope3/branches/acripps-new_Viewlet_Directive/src/zope/viewlet/meta.zcml 2007-05-30 13:06:46 UTC (rev 75997)
+++ Zope3/branches/acripps-new_Viewlet_Directive/src/zope/viewlet/meta.zcml 2007-05-30 13:41:15 UTC (rev 75998)
@@ -15,6 +15,11 @@
handler=".metaconfigure.viewletManagerDirective"
/>
+ <meta:directive
+ name="resourceViewletManager"
+ schema=".metadirectives.IResourceViewletDirective"
+ handler=".metaconfigure.resourceViewletDirective"
+ />
</meta:directives>
</configure>
Modified: Zope3/branches/acripps-new_Viewlet_Directive/src/zope/viewlet/metaconfigure.py
===================================================================
--- Zope3/branches/acripps-new_Viewlet_Directive/src/zope/viewlet/metaconfigure.py 2007-05-30 13:06:46 UTC (rev 75997)
+++ Zope3/branches/acripps-new_Viewlet_Directive/src/zope/viewlet/metaconfigure.py 2007-05-30 13:41:15 UTC (rev 75998)
@@ -187,3 +187,11 @@
args = ('registerAdapter',
new_class, (for_, layer, view, manager), interfaces.IViewlet,
name, _context.info),)
+
+def ResourceViewletDirective(_context, name, permission,
+ for_=Interface,layer=IDefaultBrowserLayer,view=IBrowserView,
+ manager=interfaces.IViewletManager,class_=None,template=None,
+ attribute='render',allowed_interface=None,allowed_attributes=None,
+ **kwargs):
+ """There is no need for a function body here because it will merely call
+ on all the parent classes (et al) for all required functionality."""
Modified: Zope3/branches/acripps-new_Viewlet_Directive/src/zope/viewlet/metadirectives.py
===================================================================
--- Zope3/branches/acripps-new_Viewlet_Directive/src/zope/viewlet/metadirectives.py 2007-05-30 13:06:46 UTC (rev 75997)
+++ Zope3/branches/acripps-new_Viewlet_Directive/src/zope/viewlet/metadirectives.py 2007-05-30 13:41:15 UTC (rev 75998)
@@ -25,6 +25,7 @@
from zope.app.publisher.browser import metadirectives
from zope.viewlet import interfaces
+from zope.app.publisher.browser import IResourceDirective
class IContentProvider(metadirectives.IPagesDirective):
@@ -102,6 +103,22 @@
required=False,
default=interfaces.IViewletManager)
+class IResourceViewletDirective(IViewletDirective,IResourceDirective):
+ """A directive to register a new viewlet and it's resource.
+
+ By registering both a viewlet *and* it's directive we save typing, and
+ complexity, by redicing the calls to the viewlet directive in the
+ configuration of a viewlet. This reduces the calls by half.
+ Author: Aaron Cripps, MUN Housing. cripps at cs.mun.ca
+ """
+
+ manager = zope.configuration.fields.GlobalObject(
+ title=_("view"),
+ description=u"The interface of the view this viewlet is for. "
+ u"(default BrowserView)""",
+ required=False,
+ default=interfaces.IViewletManager)
+
# Arbitrary keys and values are allowed to be passed to the viewlet.
IViewletDirective.setTaggedValue('keyword_arguments', True)
More information about the Checkins
mailing list