Easier development when dealing with docker-compose stacks

For some time I've had to deal with two separate, docker-compose based application stacks. One of them combining a Ruby on Rails app with a whole suite of ElasticSearch nodes, sidekiq worker, Postgresql, nginx, the whole shebang. Another is just a plain Zope/Plone stack, but the difficulties remain the same: when I wanted to do production debugging or just plain development using that environment, I needed something that can be started manually, in the whole stack. [...]

Change the authentication cookie name in Plone

Not obvious of first, there are two places to change the cookie name used in login: /acl_users/credentials_cookie_auth/manage_propertiesForm and /acl_users/session/manage_propertiesForm [...]

How to make the linked object editable in droppable collective.cover tiles

By default, collective.cover offers one mechanism to "drop" objects to their tiles, by using the "Add content" button at the top. I've received feedback that the button will not be very friendly to editors, so my solution, in this case, is really simple. In the tile schema, instead of the default: uuid = schema.TextLine( title=_(u'UUID'), required=False, readonly=True, ) redefine uuid to be such as: from plone.formwidget.contenttree import UUIDSourceBinder from z3c. [...]

Trigger cron style jobs in Plone sites without passwords

For some time the plone.recipe.zope2instance added support to execute scripts in the context of a full "Zope 2 environment", by using it such as  bin/instance run /path/to/script This can be used to launch Python scripts with full support of the Zope machinery, connected to the Zeo server, etc. The script can be generated as a console script from any Plone addon. Here's a small snippet to be used to get a " [...]

Abusing Plone Content Rules to allow Site Admin customizations of sent emails

This would be a sort of tutorial on how to implement a new plone.app.contentrules Trigger Event, how to write a new plone.stringinterp variable substitutor and how to trigger the event from a browser page (or z3c.form). This allows configuring a new trigger event from the Content Rules Plone control panel configlet and to assign a new Email action, with customizable body template. Let's say our task is to implement a contact form: [...]

How to fake fix broken persistent objects in ZODB

I have a Zope / Plone website with some old objects created by Products.feedfeeder and they store (for some weird reason) instances of BeautifulSoup objects. These objects were created with BeautifulSoup 3 and the installed version of BS is 4, which moved its classes in the bs4.* namespace. Now, running full-sweep searches in the site or a full catalog reindex fails because of these, now broken, objects. My solution, because I didn't care for those stored BeautifulSoup objects, was to fake the BeautifulSoup module and patch it into sys. [...]

How to completely disable Diazo on a specific path

I'm working on an (inherited) website that uses Plone and BackboneJS to offer a streamlined search interface over a catalog of items. My task was to apply a new Diazo theme, which worked great for the rest of the website, except for this search page. The items inserted by the Backbone app would be all garbled and wrong. In the end, I managed to isolate the problem to a single page template that would load only that SPA, and the problem still persisted, (on my development machine), while the same code ran ok on the production server. [...]

How to use pgloader to migrate sqlite database to postgresql

I needed to migrate a Kotti database, from its default sqlite file store, to Postgresql. Clued in by StackOverflow, I've tried using pgloader, but the version coming with Ubuntu is old: 2.x instead of the brand new 3.x. But the jump to 3.x meant a switch in programming languages as well: the new one is written in Lisp. I didn't want to install and compile the whole Lisp bundle just to run pgloader and I didn't find a binary distribution either, and after a recent exposure to Docker, I thought I'll give the dockerized version of pgloader a try. [...]

The case of the strange RichText widgets

On a Plone 4.3 with plone.app.widgets 1.8.0 and plone.app.contenttypes 1.1b5 installed, there's one weird bit of inconsistency: The TinyMCE widget rendered by the plone.app.contenttype's IRichText behaviour is different from any other RichText field added in the dexterity model. Even on the same page, for example, if I edit the Document dexterity type and add a rich text field, the resulting widget is different. How do I know? Try inserting an image by selecting it, in the popup dialog, from the site content browser. [...]

ZODB: How to get and read objects from an undo information

This is useful for example if you have transactions that cause writes to the database and you don't know what has been written. First, identify the ID of the transaction that you're interested. In the Undo tab of Zope, inspect the checkbox for the transaction and copy the part that looks like an id from its value. Then, in a zope debugging shell (started with bin/instance debug), I've done: >>> import base64, cPickle >>> webtid = " [...]