Archived community.zenoss.org | full text search
Skip navigation
2498 Views 4 Replies Latest reply: Oct 18, 2011 9:18 PM by Shane Scott RSS
jcurry ZenossMaster 1,021 posts since
Apr 15, 2008
Currently Being Moderated

Sep 21, 2011 4:02 PM

Overriding pt files with a ZenPack

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

  • Shane Scott ZenossMaster 1,373 posts since
    Jul 6, 2009
    Currently Being Moderated
    1. Sep 22, 2011 2:07 AM (in response to jcurry)
    Re: Overriding pt files with a ZenPack

    Jane:

     

    I did some testing. Looks like we'll need to crash configure.zcml files to override pt files in v3 & v4.

     

    --Shane

  • Chet Luther ZenossEmployee 1,302 posts since
    May 22, 2007
    Currently Being Moderated
    3. Sep 22, 2011 12:34 PM (in response to jcurry)
    Re: Overriding pt files with a ZenPack

    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.

  • Shane Scott ZenossMaster 1,373 posts since
    Jul 6, 2009
    Currently Being Moderated
    4. Oct 18, 2011 9:18 PM (in response to Chet Luther)
    Re: Overriding pt files with a ZenPack

    Chet:

     

    Awesome example.

     

    Thanks very much!

     

    Best,

    --Shane W. Scott(Hackman238)

      ZCA - community/zca/blog

More Like This

  • Retrieving data ...

Legend

  • Correct Answers - 4 points
  • Helpful Answers - 2 points