Monthly Archive for January, 2009

Override portlets or Subclassing

On http://transcyberia.info/archives/39-customizing-navigation-in-Plone3.html I found a great article on how to subclass the navigation portlet. Explanations and all. This entry is based on that article but doesn’t have all the nice explanations.

For a generic plone 3 portlet with a template portlet.pt and a module named portlet.py, this is what you need to do to subclass it. I tend to create a portlets folder in my porducts, which you have to register in the same way as the browser folder from your theme is registered. Don’t forget the __init__.py and a configure.zcml!

Copy portlet.pt template from the source egg into your theme’s portlets/ directory. Don’t copy portlet.py, but instead create your own portlet.py. It needs only the following measly five lines of code:

from source.egg.portlet import Renderer
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile

class MyPortletRenderer(Renderer):
     render = ViewPageTemplateFile('portlet.pt')

In portlets/configure.zcml put the following lines:

      <plone:portletRenderer
       portlet="source.egg.portlet.IPortletInterface"
       layer=".interfaces.IThemeSpecific"

       />

If, like in this example, the template in the renderer is called render (so render = ViewPageTemplateFile(‘portlet.pt’)) and not index or _template or something the like, you just use the template instead of creating a class for it in a special portlet.py. The subclassing also works with multiple templates or differently named ones.

<plone:portletRenderer
   portlet="source.egg.portlet.IPortletInterface"
   template="portlet.pt"
   layer=".interfaces.IThemeSpecific"
   />

Creating an ssh tunnel

Setting up a host for a server in the ssh config and creating an ssh tunnel.

For this your would have to have access to a server. Open your ssh configuration in a text editor.

gedit ~/.ssh/config

Add the server specifications.

Host host
HostName path.to.server.com
User username

Create an ssh tunnel.

ssh host -L8080:127.0.0.1:8080

Now you can reach host as if it were 127.0.0.1 (localhost). “-L8080″ stands for your local host, “127.0.0.1:8080″ stands for what you are on the other side of the tunnel.

To close the tunnel.

exit