Skip to content

Instantly share code, notes, and snippets.

🕶️
Available for training, coaching and trouble-shooting (as usual)..

Jens W. Klein jensens

🕶️
Available for training, coaching and trouble-shooting (as usual)..
Block or report user

Report or block jensens

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jensens
jensens / versionfinder.py
Created Feb 8, 2011
parses zopes instance file and returns versions used (for use in buildout)
View versionfinder.py
# versionfinder
import re
regexp = re.compile('.*\/(.*)-(.*)-py')
with open('instance', 'r') as ins:
for line in ins.readlines():
res = regexp.match(line)
if res is None:
continue
print "%s = %s" % res.groups()
@jensens
jensens / actions.py
Created Mar 2, 2011
actions to set a Navigation Root
View actions.py
from zope.interface import Interface
from zope.interface import directlyProvides
from zope.interface import noLongerProvides
from Products.Five.browser import BrowserView
from Products.CMFPlone.interfaces import INavigationRoot
from Products.CMFPlone import PloneMessageFactory as _
class IPossibleNavigationRoot(Interface):
pass
View gist:953532
from Products.Five.browser import BrowserView
class LangRedir(BrowserView):
"""language redirect"""
def __call__(self):
target = 'en-ie'
for lang in self.context.portal_languages.getRequestLanguages():
if lang in ('de-at', 'de-ch'):
target = 'de-at'
@jensens
jensens / dcwf2dot.py
Created Mar 1, 2012
generates dot file from workflows (zope python script)
View dcwf2dot.py
context.REQUEST.response.setHeader('Content-Type', 'text/plain')
print "digraph %s {" % context.getId()
wf = context
state_to_trans = []
for state in wf.states.values():
roles = state.getAvailableRoles()
roles.sort()
permtable = [ ['<FONT POINT-SIZE="10">%s</FONT>' % _ for _ in ['permission', 'acquired'] + roles ] ]
for perm in state.getManagedPermissions():
pinfo = state.getPermissionInfo(perm)
@jensens
jensens / buildout.cfg
Created Mar 29, 2012
python buildout with lxml
View buildout.cfg
[buildout]
parts = py
[py]
recipe = zc.recipe.egg
eggs = lxml
interpreter = py
@jensens
jensens / buildout.cfg
Created Apr 4, 2012
Minimla Plone 4.1
View buildout.cfg
[buildout]
find-links +=
http://effbot.org/downloads/
parts =
instance
omelette
extends =
http://dist.plone.org/release/4.1-latest/versions.cfg
@jensens
jensens / buildout.cfg
Created Apr 4, 2012
Buildout which just adds setuptools to python
View buildout.cfg
[buildout]
parts = py
[py]
recipe = zc.recipe.egg
eggs =
setuptools
interpreter = py
@jensens
jensens / action.py
Created Aug 29, 2012
Plone action menu enable feature by setting marker interface
View action.py
from zope.interface import Interface
from zope.interface import directlyProvides
from zope.interface import noLongerProvides
from Products.Five.browser import BrowserView
from Products.CMFPlone import PloneMessageFactory as _
class ISomeFeatureTarget(Interface):
pass
class IPossibleSomeFeatureTarget(Interface):
View locandy_gae.tests.py
import unittest
import doctest
from pprint import pprint
from interlude import interact
from google.appengine.ext import testbed
optionflags = doctest.NORMALIZE_WHITESPACE | \
doctest.ELLIPSIS | \
doctest.REPORT_ONLY_FIRST_FAILURE
View querystring.py
from plone.app.querystring.queryparser import getPathByUID, getNavigationRoot
def _multi_path(context, row):
values = []
for value in row.values.split():
if not '/' in value:
# It must be a UID
value = '/'.join(getPathByUID(context, value))
# take care of absolute paths without nav_root
nav_root = getNavigationRoot(context)
You can’t perform that action at this time.