Skip to content

Instantly share code, notes, and snippets.

I may be slow to respond.

Roel Bruggink jaroel

I may be slow to respond.
View GitHub Profile
jaroel / site.zcml
Created Apr 4, 2016
Minimal site.zcml to make my Plone 5 instance running without z3c.autoinclude.
View site.zcml
<include package="Zope2.App" />
<include package="Products.Five" />
<meta:redefinePermission from="zope2.Public" to="zope.Public" />
<!-- Load the meta -->
jaroel /
Created Apr 4, 2016
Outputs a constraints.txt compatible pinning from a Plone versions.cfg. Requires zc.buildout for parsing the .cfg files, naturally.
from pkg_resources import parse_version
from zc.buildout.buildout import Buildout
def get_buildout(version):
versions_url = '{version}/versions.cfg'
url = versions_url.format(version=version)
buildout = Buildout(
View .isort.cfg
jaroel /
Last active Dec 8, 2015
Unpack Plone hotfixes into parts/products
# ./ url md5hash [target basedir]
# i.e. ./ aab87c2904754a2f6374f52c441fb97f /zeoclients/
PATCHFILE="/tmp/$(basename $0).$$"
rm -rf "$PATCHFILE"
curl "$1" > "$PATCHFILE"
MD5=`openssl md5 "$PATCHFILE"|cut -d " " -f 2`
[[ $MD5 != $2 ]] && echo "Hashes do not match." && exit 1
View gist:e8f09d14b87b809dac15
stationDepartures id sc=map (\(s1,list)->(stationName $ (stationMap $ system sc) Map.! s1,list)) ( Map.toList (Map.fromListWith (++) (map (\((s1,s2),(d,start,dur))->(s2,[start])) (Map.toList (Map.filterWithKey (\(s1,s2) _ ->s1==id) (Map.unions ( times (Map.elems $ schedule sc))))))))
View gist:741ed34d0a1528792aec
Wednesday Journeys with Transmogrifier & friends or How not to get stuck in the Plone dark ages Code analysis for a better future RelStorage for mere mortals Why Plone is going to die! The Beauty and the Beast. Modern Javascript Depelopment with AngularJS and Plone ApplicationCache and Plone: An ongoing battle Easy Online Business Processes with Plone Forms and Workflow
jaroel / gist:6ea92dafd1c61dc08de9
Last active Aug 29, 2015
Show message for end user on errors with LDAP server in Plone
View gist:6ea92dafd1c61dc08de9
from plone.api.portal import show_message
from cStringIO import StringIO
import logging
fake_log_file = StringIO()
aux_logger = logging.StreamHandler(fake_log_file)
ldap_logger = logging.getLogger('event.LDAPDelegate')
jaroel / gist:5345403
Created Apr 9, 2013
Parameterised dynamic vocabulary. Shows unique values for catalog index. Pass in the index name in the schema.
View gist:5345403
from zope.schema.interfaces import IContextSourceBinder, IBaseVocabulary
class CatalogIndexValuesSource(object):
grok.implements(IContextSourceBinder, IBaseVocabulary)
def __init__(self, index_name):
self.index_name = index_name
jaroel / gist:5345392
Last active Dec 16, 2015
Parameterised dynamic vocabulary. Shows content of catalog using query with object_provides. Pass in the interface in the schema.
View gist:5345392
from zope.schema.interfaces import IContextSourceBinder, IBaseVocabulary
class CatalogObjectProvidesSource(object):
grok.implements(IContextSourceBinder, IBaseVocabulary)
def __init__(self, interface):
self.interface = interface
jaroel / gist:1688278
Created Jan 27, 2012
Count words in Plone html
View gist:1688278
catalog = context.portal_catalog
lexicon = catalog.htmlwordsplitter_lexicon
brains = catalog(Language='nl', portal_type='CoolPage')
words = dict(Title=0, Description=0, getText=0)
for brain in brains:
ob = brain.getObject()
words['Title'] = ob.Title().split()
words['Description'] = ob.Description().split()
words['getText'] = lexicon.parseTerms(ob.getText())