Skip to content

Instantly share code, notes, and snippets.

@pgrunewald
Last active July 13, 2016 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgrunewald/379b9da16f063cc7f092ba4c057232bc to your computer and use it in GitHub Desktop.
Save pgrunewald/379b9da16f063cc7f092ba4c057232bc to your computer and use it in GitHub Desktop.
Using a helper browser view in Plone
<browser:page
name="helper_view"
for="*"
permission="zope2.Public"
class=".helper_view.HelperView"
allowed_attributes="getMD5
method2
method3"
/>
Idea is to install a helper/utility browser view (it does have no template, just methods to be called).
Please note, that these files should reside in /browser of your addon (except maybe template, when it's overriden).
from Products.Five.browser import BrowserView
from your.addon import md5_function
## @brief Helper view for image macros
# @extends Products.Five.browser.BrowserView
class HelperView(BrowserView):
"""Various helper methods.
"""
def getMD5(self, string):
return md5_function(string)
<span tal:define="helper_view context/@@helper_view">
<tal:contents replace="python:helper_view.getMD5('my_string')">
MD5 of the string
</tal:contents>
</span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment