Sep 21, 2011 4:02 PM
Overriding pt files with a ZenPack
-
Like (0)
I am sure in the past I have overridden a Core pt file by one in a ZenPack but it isn't working now with 3.2. In the ZenPack __init__.py, I have :
skinsDir = os.path.join(os.path.dirname(__file__), 'skins')
from Products.CMFCore.DirectoryView import registerDirectory
if os.path.isdir(skinsDir):
registerDirectory(skinsDir, globals())
In my skins/<ZenPack name> dir I have editActionRule.pt, slightly modified, to override $ZENHOME/Products/ZenEvents/skins/zenevents/editActionRule.pt.
Reinstalled the ZenPack with zenpack --link --install <ZenPack>
zenhub restart
zopectl restart
Also tried bouncing zenoss entirely.
My file doesn't get picked up.
What have I missed?
Surely I CAN still do this??
Cheers,
Jane
Jane:
I did some testing. Looks like we'll need to crash configure.zcml files to override pt files in v3 & v4.
--Shane
Can you expand a little on this? Provide an example?
Are you saying that any ZenPack that overrode page template (.pt) files pre Zenoss 3.0, is now defunct?
Cheers,
Jane
Zenoss no longer relies on skin layers to pick the right page template for a given view. We now hook up the page templates explicitely to the classes they're related to. In many ways this is a lot cleaner. Previously you could to to some_device/editActionRule and Zope would attempt to render that page template in the device's context, which would fail.
Explanation aside, this means that you need to wire your editActionRule replacement page template using ZCML. Following convention within your ZenPack this means you would do the following.
Create the following directory structure within your ZenPack's main directory (i.e. where the daemons, datasources, etc. directories are.)
mkdir -p browser/templates
touch browser/__init__.py
Assuming you don't already have a configure.zcml.
cat > configure.zcml << EOF
<?xml version="1.0" encoding="utf-8"?>
<configure xmlns="http://namespaces.zope.org/zope">
<include package=".browser"/>
</configure>
EOF
cat > browser/configure.zcml <<EOF
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">
<browser:page
name="editActionRule"
for="Products.ZenEvents.ActionRule.ActionRule"
template="templates/editActionRule.pt"
permission="zenoss.View"
/>
</configure>
EOF
Then you can put your template in browser/templates/editActionRule.pt.
Follow Us On Twitter »
|
Latest from the Zenoss Blog » | Community | Products | Services Resources | Customers Partners | About Us | ||
Copyright © 2005-2011 Zenoss, Inc.
|
||||||||