Skip to content

Instantly share code, notes, and snippets.

View toutpt's full-sized avatar
👨‍💻

Jean-Michel toutpt

👨‍💻
View GitHub Profile
def getToolByName(obj, name, default=_marker):
""" Get the tool, 'toolname', by acquiring it.
o Application code should use this method, rather than simply
acquiring the tool by name, to ease forward migration (e.g.,
to Zope3).
"""
tool_interface = _tool_interface_registry.get(name)
@toutpt
toutpt / storage.py
Last active December 13, 2018 18:52
The best way to store settings/data using zope annotations
from zope.annotation.interfaces import IAnnotations
from persistent.list import PersistentList
from Products.CMFCore.utils import getToolByName
FAVBY = "collective.favoriting.favoritedby"
def setupAnnotations(context):
"""
set up the annotations if they haven't been set up
@toutpt
toutpt / feature.js
Created December 20, 2013 14:32
open all img in a plone site using overlay
var openimginoverlay = function(){
$('img[src$="image_tile"],img[src$="image_thumb"],img[src$="image_mini"],img[src$="image_preview"]')
.each(function(){
var $this = $(this);
if (!$this.parent().is('a')){
$this.prepOverlay({
subtype: 'image',
urlmatch: '/image_.+$',
urlreplace: '',
});
/*global _:false */
/**
* nom
* code
* type
* Site parent
* Service mainteneur
* long
* lat
@toutpt
toutpt / resources.js
Last active March 21, 2016 11:22
angular require extra libs
(function () {
'use strict';
/*global _:false */
/*global angular:false */
/*global SWIF_RESOURCES_VERSION:false */
/*jshint latedef:false */
/* config.json file available throw settings.app:
"resources": {
"scripts": {