Skip to content

Instantly share code, notes, and snippets.

View pgrunewald's full-sized avatar

Paul Grunewald pgrunewald

View GitHub Profile
@pgrunewald
pgrunewald / browser_view.py
Created May 23, 2018 15:06
Overriding language binding programmically
class YourBrowserView:
def some_method(self):
original_lang = self.context.REQUEST['LANGUAGE']
original_lang_binding = self.context.REQUEST['LANGUAGE_TOOL']
target_language = 'de'
try:
@pgrunewald
pgrunewald / configure.zcml
Created May 23, 2018 14:51
Implementing an own language negotiator
<configure>
<!-- Per request language overriding -->
<adapter
factory=".negotiate_language.NegotiateLanguage"
for="* your.addon.interfaces.IAddonInstalled"
provides="Products.PloneLanguageTool.interfaces.INegotiateLanguage"
/>
</configure>
@pgrunewald
pgrunewald / contents.css
Created May 23, 2018 11:06
CKEditor widget demo
.simplebox {
padding: 8px;
margin: 10px;
background: #eee;
border-radius: 8px;
border: 1px solid #ddd;
box-shadow: 0 1px 1px #fff inset, 0 -1px 0px #ccc inset;
}
@pgrunewald
pgrunewald / configure.zcml
Last active April 9, 2018 16:06
Disable Theming/Diazo for AJAX Requests
<configure
xmlns = "http://namespaces.zope.org/zope"
xmlns:five = "http://namespaces.zope.org/five"
xmlns:genericsetup = "http://namespaces.zope.org/genericsetup"
xmlns:monkey = "http://namespaces.plone.org/monkey"
i18n_domain = "tud.profiles.webcms">
<!-- Disable Theming/Diazo in transformation chain if appropriate -->
<adapter
name="your.addon.disable_theme"
@pgrunewald
pgrunewald / buildout.cfg
Created June 27, 2017 07:57
testing with buildout
[test]
recipe = zc.recipe.testrunner
eggs =
${buildout:eggs}
defaults = ['--auto-color', '--auto-progress']
@pgrunewald
pgrunewald / ajax_view.py
Created May 30, 2017 16:02
Browser view /w Ajax
from Products.Five.browser import BrowserView
class AjaxView(BrowserView):
"""Various callable methods.
"""
def plus(self):
return int(self.request.form('a')) + int(self.request.form('b'))
def minus(self):
@pgrunewald
pgrunewald / Helper browser view.txt
Last active July 13, 2016 08:22
Using a helper browser view in Plone
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).
@pgrunewald
pgrunewald / configure.zcml
Created May 4, 2016 15:08
Overriding listing_summary.pt without jbot.
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:plone="http://namespaces.plone.org/plone"
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="plone">
<include package="plone.app.contentmenu" />
<!-- VIEWS FOR PLONE SITE ROOT -->