Skip to content

Instantly share code, notes, and snippets.

View thet's full-sized avatar

Johannes Raggam thet

View GitHub Profile
@thet
thet / gist:11217449
Created April 23, 2014 14:29
plone.app.contenttypes migration helpers
def attr_migrator(old, new, old_name, new_name):
field = old.getField(old_name)
if not field:
return
val = field.get(old)
val_str = str(val)
if old_name == 'teacher':
if not isinstance(val, list):
val = []
teachers = []
[buildout]
parts = instance
extends = http://dist.plone.org/release/4-latest/versions.cfg
find-links = http://dist.repoze.org/
versions = versions
[instance]
recipe = plone.recipe.zope2instance
eggs =
Plone
### Keybase proof
I hereby claim:
* I am thet on github.
* I am thet (https://keybase.io/thet) on keybase.
* I have a public key whose fingerprint is 8667 B704 EBB4 8E94 447F 5EF6 5B89 8D31 0C43 8007
To claim this, I am signing this object:
@thet
thet / instancebehaviors.py
Created November 1, 2012 00:04
plone/dexterity per-instance behaviors
"""Per instance behaviors for Plone's Dexterity.
<adapter
for=".interfaces.IBasetype"
factory=".instancebehaviors.DexterityInstanceBehaviorAssignable" />
Also see:
http://opkode.net/media/blog/plone-and-dexterity-enable-behaviors-per-content-type-instance
"""
from Products.Archetypes.Field import *
from Products.Archetypes.Storage import *
from Products.Archetypes.Widget import *
from Products.Archetypes.fieldproperty import ATDateTimeFieldProperty
from Products.Archetypes.fieldproperty import ATFieldProperty
from Products.Archetypes.athistoryaware import ATHistoryAwareMixin
from Products.Archetypes.fieldproperty import ATReferenceFieldProperty
from Products.Archetypes.annotations import AT_ANN_STORAGE
from Products.Archetypes.annotations import AT_FIELD_MD
from Products.Archetypes.ClassGen import AT_GENERATE_METHOD
@thet
thet / gist:7155911
Created October 25, 2013 14:51
g24 geojson , 200 items url: http://localhost:8080/Plone/places/geojson?b_size=200&b_start=10 after deployment, this should be available under: http://beta.g24.at/geosjon[?OPTIONAL&URL=PARAMETERS]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
[buildout]
parts =
instance
zopepy
test
packages
extends =
https://raw.github.com/plone/buildout.coredev/5.0/sources.cfg
https://raw.github.com/plone/buildout.coredev/5.0/checkouts.cfg
@thet
thet / togglescrolling.sh
Created January 14, 2016 10:01
Toggle touchpad scrolling on Gnome 3 via dconf
#!/bin/sh
# Toggle touchpad scrolling on Gnome 3 via dconf/gsettings between
# 'two-finger-scrolling' and 'edge-scrolling'.
# This can be useful for touchpad users using two-finger-scoll and want
# to open the context menu via two-finger-click on the right position.
CURRENT=$(gsettings get org.gnome.desktop.peripherals.touchpad scroll-method)
echo $CURRENT
@thet
thet / fix_image_scales.py
Created December 8, 2015 12:35
fix image scales from archetypes scales to dx scales, old scale names to new scale names
# -*- coding: utf-8 -*-
from Products.CMFCore.utils import getToolByName
from plone.app.textfield.value import RichTextValue
from zope.component.hooks import getSite
import logging
log = logging.getLogger(__name__)
@thet
thet / registry.xml
Last active January 15, 2018 11:28
Plone: Add ``object_provides`` criteria to query string for use in collections. Put code in ``registry.xml`` and create a .tar.gz, then upload it via portal_setup and make sure to untick "Purge existing settings".
<registry xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<!-- Add ``object_provides`` criteria to query string for use in collections.
Put code in ``registry.xml`` and create a .tar.gz, then upload it via
portal_setup and make sure to untick "Purge existing settings". -->
<records interface="plone.app.querystring.interfaces.IQueryField"
prefix="plone.app.querystring.field.object_provides">
<value key="title">object_provides</value>
<value key="description">Search for provided interfaces</value>
<value key="enabled">True</value>
<value key="sortable">True</value>