Skip to content

Instantly share code, notes, and snippets.

View simahawk's full-sized avatar

Simone Orsi simahawk

View GitHub Profile
@simahawk
simahawk / advancedpage.py
Last active August 29, 2015 14:00
A dexterity advanced page that renders ZPT markup
#-*- coding: utf-8 -*-
from Acquisition import aq_inner
from Acquisition import aq_base
from five import grok
from zope import schema
from zope.component import getMultiAdapter
# ~/.gitconfig
[branch]
autosetupmerge = true
[push]
default = current
[core]
excludesfile = .gitignore
@simahawk
simahawk / ldap.cfg
Created June 3, 2015 10:57
LDAP setup via buildout
[buildout]
parts +=
openldap
python-ldap
eggs +=
plone.app.ldap
[openldap]
recipe = zc.recipe.cmmi
@simahawk
simahawk / main.js
Created July 27, 2015 07:59
Plone z3c.form datetime widget pure JS
(function ($) {
"use strict";
if ((typeof window.widgets) === 'undefined') {
window.widgets = {};
}
var widgets = window.widgets;
widgets.CalendarWidget = function (wrapper, settings) {
var self = this;
@simahawk
simahawk / gist:1286732
Created October 14, 2011 10:10
lfs template tag example
from django import template
register = template.Library()
import lfs.cart.utils
from lfs.core.models import Shop
from lfs.caching.utils import lfs_get_object_or_404
@register.inclusion_tag("lfs/disclaimer.html")
def disclaimer():
@simahawk
simahawk / gist:2043829
Created March 15, 2012 11:47
zeo conf for buildout
[buildout]
parts +=
zeoserver
client1
client2
cljobs
cldebug
[zeoserver]
recipe = plone.recipe.zeoserver
@simahawk
simahawk / zodb_keyerror_tmp_fix.py
Created April 20, 2012 13:19
temporary fix for ZODB connection KeyError
# temporary hack for fixing ZODB connection error
from ZODB import FileStorage, DB
dbname = 'my_missing_db'
path = 'path/to/missing/storage.fs'
storage = FileStorage.FileStorage(path)
db = DB(storage)
# app is the zope instance in debug mode
app._p_jar._db.databases[dbname] = db
"""
Use with
bin/instance run export_skin_folder.py
This script will extract the portal_skins folder
named in SKINFODLER_NAME to the DEST directory
"""
import os
import sys
PLONE_PORTAL = 'Plone'
# custom_cookie_consent PT
<metal:macro define-macro="message">
<tal:block
define="ps context/@@plone_portal_state;
language ps/language;
root_url ps/navigation_root_url;
privacy_url_it string:${root_url}/it/privacy;
privacy_url_en string:${root_url}/en/privacy;"
@simahawk
simahawk / gist:4707567
Last active December 12, 2015 03:29
register plone user and notify if needed
def _register(self, username, properties):
member = None
try:
# force encoding to utf8
for k,v in properties.items():
properties[k]= v.encode('utf8')
member = self.regtool.addMember(username, properties['fullname'], properties['email'])
member.setMemberProperties(properties)
self.created += 1
msg = "created user '%s' -> %s" % (username,str(properties))