Skip to content

Instantly share code, notes, and snippets.

View ale-rt's full-sized avatar

Alessandro Pisa ale-rt

View GitHub Profile
@ale-rt
ale-rt / cssfrompngs
Created May 14, 2015 16:32
Script that creates css rules to add background png images with data-uris
#!/usr/bin/env python
from PIL import Image
from base64 import encodestring
import sys
template = '''.%(classname)s {
width: %(width)spx;
height: %(height)spx;
background-repeat: no-repeat;
@ale-rt
ale-rt / dx-overrire-nexturl.py
Created November 19, 2015 08:16
Dexterity example: override nextURL
class BaseEditForm(DefaultEditForm):
def nextURL(self):
''' Try to guess in a smart way what will bethe next url
'''
next_url = super(BaseEditForm, self).nextURL()
current_tab = getattr(self, 'tab_id', '')
if not current_tab:
return next_url
if not current_tab in self.wizard_tabs:

If you got this error:

kees@zeno:~/Projects/buildout.coredev$ xvfb-run ./bin/test -m Products.CMFPlone
Running Products.CMFPlone.testing.CMFPloneLayer:Functional tests:
  Set up plone.testing.zca.LayerCleanup in 0.000 seconds.
  Set up plone.testing.z2.Startup in 0.147 seconds.
  Set up plone.app.testing.layers.PloneFixture in 5.623 seconds.
  Set up plone.app.event.testing.PAEventLayer in 0.562 seconds.
  Set up plone.app.contenttypes.testing.PloneAppContenttypes in 1.353 seconds.
  Set up Products.CMFPlone.testing.ProductsCMFPloneLayer in 0.078 seconds.
@ale-rt
ale-rt / gist:7820888
Last active December 30, 2015 11:09
SQLLite
apt-get install libsqlite3-0 libsqlite3-dev sqlite3
[saconfig]
recipe = collective.recipe.template
sqlalchemy_url = sqlite:///${buildout:directory}/var/albo.db
sqlalchemy_extras = 
input = ${buildout:directory}/templates/arpa.albo.zcml.in
output = ${buildout:directory}/etc/arpa.albo.zcml
def plonereload(user="admin", password='admin'):
''' Reload Plone
'''
from requests import get
from lxml.html import fromstring
auth = (user, password)
response = get('http://localhost:7081/reload?action=code', auth=auth)
try:
print fromstring(response.text).find('.//pre').text
@ale-rt
ale-rt / gist:8685751
Last active January 4, 2016 22:09
How to make collective.lineage and collective.simplesocial work together
Just add to the zcml-additional those lines
```
[instance]
...
zcml-additional =
<configure xmlns="http://namespaces.zope.org/zope">
<adapter for="collective.lineage.interfaces.IChildSite"
factory="collective.simplesocial.browser.configlet.FacebookSettingsAdapter"
provides="collective.simplesocial.browser.interfaces.IFacebookSettings"
/>
# coding=utf-8
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManager import setSecurityPolicy
from collective.jsonify.export import export_content
from logging import DEBUG
from logging import getLogger
from Products.CMFCore.tests.base.security import OmnipotentUser
from Products.CMFCore.tests.base.security import PermissiveSecurityPolicy
from Testing.makerequest import makerequest
@ale-rt
ale-rt / gist:3c7741dd2013f364ac8370bc07273727
Created April 27, 2016 16:02
bin/instance run this script to dump your Plone site into an a folder
# coding=utf-8
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManager import setSecurityPolicy
from collective.jsonify.export import export_content
from logging import DEBUG
from logging import getLogger
from Products.CMFCore.tests.base.security import OmnipotentUser
from Products.CMFCore.tests.base.security import PermissiveSecurityPolicy
from Testing.makerequest import makerequest
[instance]
eggs+=
${hotfix:eggs}
[hotfix]
recipe = mr.scripty
eggs=
from urllib import urlopen
version = self.buildout['versions']['Plone']
base_url = 'https://raw.githubusercontent.com/starzel/buildout/master/linkto/hotfixes/%s.cfg'
[style]
# Align closing bracket with visual indentation.
align_closing_bracket_with_visual_indent=True
# Allow dictionary keys to exist on multiple lines. For example:
#
# x = {
# ('this is the first element of a tuple',
# 'this is the second element of a tuple'):
# value,