Last active
July 13, 2016 08:22
-
-
Save pgrunewald/379b9da16f063cc7f092ba4c057232bc to your computer and use it in GitHub Desktop.
Using a helper browser view in Plone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<browser:page | |
name="helper_view" | |
for="*" | |
permission="zope2.Public" | |
class=".helper_view.HelperView" | |
allowed_attributes="getMD5 | |
method2 | |
method3" | |
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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