Skip to content

Instantly share code, notes, and snippets.

View simonedeponti's full-sized avatar

Simone Deponti simonedeponti

View GitHub Profile
@simonedeponti
simonedeponti / attachments.py
Last active August 29, 2015 14:22
Attachment API
def extract_and_add(file_upload, obj, workspace=None, token=None):
"""Extracts temporary attachments from storage and attaches them into `obj`
Extract file data `from file_upload`, create file/image objects and add
them as attachments to ``obj``. If workspace and token are given, reuse
previously uploaded temporary attachments if they exist.
"""
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@simonedeponti
simonedeponti / Dockerfile
Created January 7, 2015 11:18
Fig example setup
FROM python:2.7-wheezy
RUN mkdir /buildout
ADD . /buildout
WORKDIR /buildout
RUN python bootstrap.py
RUN bin/buildout
.sub-nav {
h3 { // Città, scritto grosso
}
p { // Stili per Cultura
}
ul {
li {
a {
}
}
@simonedeponti
simonedeponti / utils.py
Last active August 29, 2015 14:01
Get all interfaces and behaviors
from zope.schema import getFields
from zope.interface import providedBy
from zope.interface import implementedBy
from zope.component import getUtility
from zope.component import queryUtility
from plone.behavior.interfaces import IBehavior
from plone.behavior.interfaces import IBehaviorAssignable
from plone.dexterity.interfaces import IDexterityFTI
from plone.dexterity.utils import resolveDottedName
@simonedeponti
simonedeponti / traverser.py
Created May 27, 2014 09:59
Rest API example
import json
from zope.interface import Interface
from zope.interface import implementer
from zope.interface import alsoProvides
from zope.component import adapter
from zope.traversing.interfaces import ITraversable
from zope.publisher.interfaces.http import IHTTPRequest
from ZPublisher.BaseRequest import DefaultPublishTraverse
from Products.Five.browser import BrowserView
from Products.CMFPlone.interfaces.siteroot import IPloneSiteRoot
import types
from signals_ahoy.signals import form_init
class ExtraHandler(object):
signal = None
@classmethod
def hook(cls, form_class):
cls.signal.connect(cls(), sender=form_class)
@simonedeponti
simonedeponti / utils.py
Created January 3, 2012 17:21
Form modification etc.
import types
from signals_ahoy.signals import form_init
class ExtraBase(object):
def __init__(self, name, instance):
self.name = name
self.instance = instance