Skip to content

Instantly share code, notes, and snippets.

@gforcada
gforcada / normalize_content_type_objects_fields.py
Created Feb 14, 2020
Normalize all fields of any content type being created (one has to hook that to an event handler)
View normalize_content_type_objects_fields.py
# -*- coding: utf-8 -*-
from plone.app.textfield import RichText
from plone.app.textfield.value import RichTextValue
from plone.behavior.interfaces import IBehavior
from plone.dexterity.interfaces import IDexterityFTI
from zope.component import getUtility
from zope.schema import Text
from zope.schema import TextLine
import unicodedata
@gforcada
gforcada / remove_zc_async.py
Created Jan 18, 2016
Remove zc.async queue
View remove_zc_async.py
from App.config import getConfiguration
import transaction
configuration = getConfiguration()
db = configuration.dbtab.getDatabase(name='main')
tm = transaction.TransactionManager()
conn = db.open(transaction_manager=tm)
tm.begin()
View gist:e6511de38e8da9af0df9
2015-08-12 15:22:04 INFO ZServer HTTP server started at Wed Aug 12 15:22:04 2015
Hostname: 0.0.0.0
Port: 8080
2015-08-12 15:22:06 WARNING SecurityInfo Conflicting security declarations for "<AccessControl.SecurityInfo.ClassSecurityInfo object at 0x7fbd26c9c1d0>"
2015-08-12 15:22:06 WARNING SecurityInfo Conflicting security declarations for "<AccessControl.SecurityInfo.ClassSecurityInfo object at 0x7fbd26c9c1d0>"
2015-08-12 15:22:06 WARNING SecurityInfo Class "BlobWrapper" had conflicting security declarations
2015-08-12 15:22:06 WARNING SecurityInfo Conflicting security declarations for "<AccessControl.SecurityInfo.ClassSecurityInfo object at 0x7fbd26cff9d0>"
2015-08-12 15:22:06 WARNING SecurityInfo Conflicting security declarations for "<AccessControl.SecurityInfo.ClassSecurityInfo object at 0x7fbd26cff9d0>"
2015-08-12 15:22:06 WARNING SecurityInfo Class "BlobField" had conflicting security declarations
2015-08-12 15:22:07 INFO Plone OpenID system packages not installed, OpenID support not available
@gforcada
gforcada / invalid_tickets_dev_plone_org.js
Created Apr 26, 2015
Easily close dev.plone.org tickets as invalid with greasemonkey
View invalid_tickets_dev_plone_org.js
// ==UserScript==
// @name dev.plone.org close bug as invalid
// @namespace plone
// @include https://dev.plone.org/ticket/*
// @version 1
// @grant none
// @run-at document-end
// ==/UserScript==
$(document).ready(function () {
View import_error.py
# run it on a buildout.coredev checkout, plone 5 branch
# save its output so that you have the same imports as on ``pkg_resources.py``
import os
for folder in os.listdir('src/'):
print("""
try:
import {0}
except ImportError:
print('{0} not found')
@gforcada
gforcada / warmup_plone.py
Last active Dec 25, 2015
Script that (re)starts a Plone instance, loads its main page and all links within the Plone instance that are on the main page (some filters provided)
View warmup_plone.py
# -*- coding: utf-8 -*-
# ----------------------------------------------------------------------------
# Script to warm up the instance.
#
# The script starts/restarts the instance and measures the time it takes the
# instance to become responsive. Afterwards it crawls the front-page for links
# and warms up these resources.
# ----------------------------------------------------------------------------
from datetime import datetime