Skip to content

Instantly share code, notes, and snippets.

View toutpt's full-sized avatar
👨‍💻

Jean-Michel toutpt

👨‍💻
View GitHub Profile
@toutpt
toutpt / tags.txt
Created December 9, 2012 18:08
plone.org.tags
auth
basic content types
commerce
communication
datetime
examples
integration
dev
documentation
educational
@toutpt
toutpt / mypypi.py
Created December 9, 2012 20:16
my pypi release
import xmlrpclib
import pprint
client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
packs = client.user_packages('toutpt')
infos = []
BLACKLIST = [
'epwithgis.openlayers',
'pasteFunBot',
'Products.AROfficeTransforms',
@toutpt
toutpt / rule.py
Last active December 10, 2015 13:59
Plone Rule Managment with python
import logging
from zope import interface
from zope.component import getUtility, getMultiAdapter
from Products.Five.browser import BrowserView
from Products.statusmessages.interfaces import IStatusMessage
from plone import api
from cirb.blog.interfaces import IBlogContainer
from plone.contentrules.rule.interfaces import IRuleAction, IRuleCondition
@toutpt
toutpt / .travis.yml
Last active December 11, 2015 10:19
This is boiler plate to use travis-ci in your plone addon
language: python
python: 2.7
env:
- TARGET=test
- TARGET=coverage.sh
- TARGET=python-validation.sh
# - TARGET=css-validation.sh
# - TARGET=js-validation.sh
@toutpt
toutpt / buildout.cfg
Created February 26, 2013 21:27
supervisor buildout example
recipe = collective.recipe.supervisor
plugins =
superlance
port = 9001
user = mustapha
password = secret
serverurl = http://supervisor.mustap.com
programs =
10 zeo ${zeo:location}/bin/runzeo ${zeo:location}
20 instance1 ${instance1:location}/bin/runzope ${instance1:location} true
@toutpt
toutpt / ismobile.py
Created April 11, 2013 10:16
detect mobile browser for Plone
# Ported by Matt Sullivan http://sullerton.com/2011/03/django-mobile-browser-detection-middleware/
import re
from Products.Five.browser import BrowserView
reg_b = re.compile(r"(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino", re.I|re.M)
reg_v = re.compile(r"1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)
@toutpt
toutpt / googlexxxxx.py
Created August 26, 2013 08:14
google analytics file for Plone with diazo
# Add this as python scrip tin the ZMI
res = "CONTENT OF THE FILE GOOGLE HAS GAVE YOU"
context.REQUEST.response.setHeader('X-Theme-Disabled', 'True')
return res
@toutpt
toutpt / dump_all_resources.py
Created August 27, 2013 09:11
This is a script to get all browser:resources from a Plone install
from zope.publisher.interfaces.browser import IDefaultBrowserLayer,\
IBrowserPublisher
from zope.component.hooks import setSite
import zope.interface
from zope.component._api import getAdapters
import shutil
import os
from Testing import makerequest
portal = app.restrictedTraverse('adria-rcse')
@toutpt
toutpt / removefss.py
Created September 26, 2013 19:55
Script to migrate FSS to blob. You have to write an uprade step and put this code inside. Most of the time you need to adapt it to your project / content types
def upgrade_fss2attr_storage(portal_setup):
"""We use fss on plone3, so we need first to come back to default
plone so the migration of plone will next do the job to go on blob"""
site = portal_setup.aq_parent
#fss2attributestorage
from cStringIO import StringIO
from Products.Archetypes.Storage import AttributeStorage
from iw.fss.FileSystemStorage import FileSystemStorage
# attr_storage = AttributeStorage()
fss_storage = FileSystemStorage()
@toutpt
toutpt / get_browser_views_used.py
Created September 26, 2013 20:01
This script can be used as Python Script in ZMI
catalog = container.portal_catalog
types = container.portal_types.objectIds()
views = {}
for t in types:
brains = catalog(portal_type=t)
for brain in brains:
ob = brain.getObject()
layout = ob.getLayout()