Skip to content

Instantly share code, notes, and snippets.

View gforcada's full-sized avatar
🌥️

Gil Forcada Codinachs gforcada

🌥️
View GitHub Profile
@gforcada
gforcada / normalize_content_type_objects_fields.py
Created February 14, 2020 10:26
Normalize all fields of any content type being created (one has to hook that to an event handler)
# -*- 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 January 18, 2016 09:57
Remove zc.async queue
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()
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 April 26, 2015 19:51
Easily close dev.plone.org tickets as invalid with greasemonkey
// ==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 () {
# 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 December 25, 2015 21:08
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)
# -*- 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