Someplace nice


I recently attended Plone Conference 2012, in Arnhem, Holland. As usual the conference was great, with some excellent talks. One of the main talks that caught my attention, was the talk on plone.api. 

I had heard bits and pieces about an api for plone a couple of months prior, but had yet to look into it further. My initial reaction was, “why didn’t we think of this before?”. There are parts of plone and zope, that are quite inconsistent. Naming conventions change around quite a bit and imports can be from obscure parts of different eggs, so an api to simplify the main jobs that we do 80% of the time is a great idea.

I was lucky enough to be able to stay for the sprints, so I got involved in plone.api along with some other plone people. It’s still in the beta phase so there were a few functions that hadn’t been implemented yet, but by the end of the sprints, we’d filled in most of the gaps.

The great thing about this api, is it makes regular tasks like content creation, user manipulation and creating and manipulating groups really easy. Here is an example of how you would get the portal with plone.api:

from plone import api
portal = api.portal.get()

Which is so much easier to remember than either using the porta_url tool or the plone_portal_state multiadapter. Creating content is just as easy:

from plone import api
# First get the portal
portal = api.portal.get()

# Now we can create a document
doc= api.content.create(
title='My Content',

One last example, getting a user:

from plone import api
user = api.user.get(username='adam')

plone.api is just about in beta phase now, but it’s definitely worth checking out. You can read more here: read the docs

Plone “events”

Recently I was looking for a list of all events available in plone. By ‘events’ what I actually mean is:

Zope provides an events system. Various components (e.g the standard add and edit forms) notify any number of event subscribers (also known as event handlers) of a particular event.

So these are ‘events’ you can subscribe to and trigger custom code when they are fired. I wasn’t able to find a complete list so I’ve decided to compile one myself:

From zope.lifecycleevent.interfaces:

  • IObjectCreatedEvent
  • IObjectCopiedEvent
  • IObjectModifiedEvent

From Products.Archetypes.interfaces:

  • IObjectInitializedEvent
  • IWebDAVObjectInitializedEvent
  • IObjectEditedEvent
  • IWebDAVObjectEditedEvent
  • IEditBegunEvent
  • IEditCancelledEvent


  • IObjectMovedEvent
  • IObjectAddedEvent
  • IObjectRemovedEvent
  • IContainerModifiedEvent

From Products.CMFCore.interfaces:

  • IWorkflowActionEvent
  • IActionWillBeInvokedEvent
  • IActionRaisedExceptionEvent
  • IActionSucceededEvent

From Products.DCWorkflow.interfaces:

  • ITransitionEvent
  • IBeforeTransitionEvent
  • IAfterTransitionEvent

For more information visit the following links:

Plone limiting catalog search results

After some confusion today regarding the ‘sort_limit’ index in plone’s catalog, I discovered the following:

The sort_limit is only a hint for the search algorhitms and can potentially return a few more items, so it’s preferable to use both sort_limit and slicing simultaneously

Discovered this on the following page and it seems like a good resource for any question regarding catalog indexing in plone: querying-the-catalog

mr.developer svn certification issue

Mr.Developer is a good little tool to use in conjunction with buildout, but there is one problem I ran into:

red@byers:/home/zope/plone4Test/4.0$ ./bin/buildout 
mr.developer: Updating 'Products.PasswordResetTool' with subversion.
mr.developer: Updating 'Products.ATContentTypes' with subversion.
mr.developer: Updating 'Products.CMFEditions' with subversion.
mr.developer: Updating 'Products.Archetypes' with subversion.
mr.developer: Checking out 'kss.core' with subversion.
mr.developer: svn: OPTIONS of '': Server certificate verification failed: issuer is not trusted (
mr.developer: Updating 'Products.PlonePAS' with subversion.
mr.developer: Updating 'Products.TinyMCE' with subversion.
mr.developer: Updating '' with subversion.
mr.developer: Updating 'Plone' with subversion.
mr.developer: There have been errors, see messages above.

As of the writing of this post, this is an open issue in mr.developer. A quick and dirty work around is to just check out the code manually from svn, accept the certificate permanently then re-run buildout.

Converting a month name from a string to an int

I was recently writing a python script where a function was passed a month name as a string and I wanted to get out the month number as an int based on that string.

I found quite a few posts about going the other way, but this is how I managed to do it:

import calendar

list(calendar.month_name).index(‘<insert month name here>’)

Phorm hits back

Phorm have hit back against all the bad press they’ve been getting with a new site:

They are trying very very hard to make it seem as if all the bad press they are getting is completely unfounded and that certain people are out to bring their company down. Well, let’s imagine for a second that what they say is true and the Phorm system is completely annoymous, there are no records kept and they are not going to inject any code; even in this case, people aren’t going to be singing Phorm’s praises and saying how great they are because, truth be told, people hate online advertising. That’s the bottom line. People don’t want another way they can be advertised at. As Bill Hicks once said:

" By the way if anyone here is in advertising or marketing… kill yourself."


Phorm have come up quite a lot in the main stream media recently. It’s something I read up on a little while ago. In short they’re a company that specialise in targeted advertising based on deep packet inspection. It is not clear how Phorm will then deliver these targeted advertisments but as they will have servers at the ISP level, it is possible for the to redirect or even inject HTML or javaScript into the pages that are being delivered.

There are a few things you can do to stop Phorm:

  1. Use an ISP that doesn’t have any deal with Phorm. The three who are confirmed to at the moment are Virgin media, BT and talktalk.
  2. Email website-exclusion at and have your own site excluded from their system.
  3. Spread the word. Join the facebook group, blog about it and generally let people know what is going on with their ISP.
riders 08

riders 08

lasers: laser aimed at a mirror ball

lasers: laser aimed at a mirror ball

Dropped cell phone calls continue to be a problem. To me, the worst part about it is that after the call is dropped, nobody knows what to do. Who should call whom? If there is no protocol stating what to do in this case, you will likely end up calling each other back at the same time. This can be very frustrating, because both parties will get voice mail.

I have therefore come up with a protocol which I have been using with all of my friends and am trying to promote throughout the world:

Whenever a call is inadvertently dropped, the party who initiated the original call shall initiate the new call.

Why is this the right way to handle it?

* Most other ideas revolve making a decision on who caused the drop, or who has free minutes left, etc. This only works if it is guaranteed that the answer to these questions are known. A proper protocol must be able to be absolutely determined without specific knowledge.
* It’s easy to redial

Simple, right? It has saved me time and frustration, and I hope it helps you too.