[Zope3-Users] Seeking a ZCML Example for a CSSViewlet
Jeff Rush
jeff at taupro.com
Fri Oct 6 21:29:39 EDT 2006
I've got viewlets working fine (really cool too!) but I'm stumped on getting a
CSSViewlet declared. Googling doesn't show anyone using CSSViewlets but
hopefully someone who implemented it might clarify.
The doc files show how to do it with pure Python and the utility function
viewlet.viewlet.CSSViewlet but I need it using ZCML. I'm trying:
<browser:viewlet
name="success.css-link"
manager=".interfaces.IStylingLinks"
permission="zope.Public"
media="screen"
rel="css"
class="zope.viewlet.viewlet.CSSResourceViewletBase"
/>
This bypasses the utility function and generates an error about there being no
'index' attribute, which is the small template file containing the
parameterized HTML link tag, in the result class.
So I give it a template file, although I really hate putting such a full path
in my component ZCML file:
template="/usr/share/zope-3.3.0-py2.4/lib/python/zope/viewlet/css_viewlet.pt"
And now it errors out about a missing '_path' class attribute, which is passed
into the utility function.
I've also thought about passing in the utility function via a 'factory='
parameter but the viewlet directive doesn't support such a parameter. And
I've tried just passing in the utility function on a 'class=' parameter,
figuring maybe it just wants a callable. No luck, it wants a real class to
pass into type() for instantiation.
It's only seven lines of ZCML but I sure can't see how to use it properly.
Next I'll just roll my own ZCML directive but it seems there ought to be a way
to use CSSViewlet as intended and I'm just missing it.
Help please?
-Jeff
More information about the Zope3-users
mailing list