Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View lukasgraf's full-sized avatar

Lukas Graf lukasgraf

  • 4teamwork AG
  • Bern, Switzerland
View GitHub Profile
@lukasgraf
lukasgraf / monkey.py
Created December 9, 2013 20:37
Patching Dexterity Container to use AddPortalContent for manage_pasteObjects
from plone.dexterity.content import Container
# Change permission for manage_pasteObjects to "Add portal content"
# See https://dev.plone.org/ticket/9177
# XXX Find a way to do this without patching __ac_permissions__ directly
def drop_protected_attr_from_ac_permissions(attribute, classobj):
new_mappings = []
for mapping in Container.__ac_permissions__:
perm, attrs = mapping
@lukasgraf
lukasgraf / upload_headers.pt
Last active December 19, 2015 11:39
UploadHeaders view
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="context/main_template/macros/master"
i18n:domain="opengever.maintenance">
<head>
<metal:head metal:fill-slot="head_slot">
<style>
@lukasgraf
lukasgraf / coldist.py
Created August 21, 2011 14:42
Distributing items across columns
from math import ceil
class ColumnDistributor(list):
"""Distributes a list of items across a given number of columns.
>>> items = list('ABCDEFGHIJKLM')
>>> columns = ColumnDistributor(items)
>>> columns.distribute(4)
>>> for c in columns: