Wednesday, November 26, 2008

MailHost issue: validateSingleEmailAddress

When registering a new member, i got an error message that said mail could not be sent because validateSingleEmailAddress failed.

I also found that i could not delete my MailHost object's ESMTP loginname and password, neither through the Plone interface nor through the ZMI.

This link provided the answer: Throw away your MailHost, and replace it by a SecureMailHost with id 'MailHost'. Which works!

Although i still cannot empty the ESMTP settings, but that doesn't keep me from registering members.

Wednesday, November 19, 2008

Using Plone's Title-to-id conversion in a script using an External Method

I tried to plug into Plone's title-to-id conversion machinery in a script which creates new objects. Unfortunately, due to restricted python, doing certain imports is not allowed. I fixed it using an external method. I placed the module "" my product's Extensions directory:

from zope.component import queryUtility
from plone.i18n.normalizer.interfaces import IIDNormalizer

def convertTitleToId(title):
"""Plug into plone's id-from-title machinery.
title = title.decode('utf-8')
newid = queryUtility(IIDNormalizer).normalize(title)
return newid

To my, i added a new method:

def installExternalMethod(portal, out, module, method, project, id=None):
Install external method
if not id:
id = method
print >> out, "Installing external method %s for %s" % (id, project)
if not id in portal.objectIds():
em = ExternalMethod(
title='%s(%s)' % (id, method),
module='%s.%s' % (project, module) ,
portal._setObject(id, em)

and i added
installExternalMethod(site, out, 'MyProductExternalMethods', 'convertTitleToId', PROJECTNAME)
to the postInstall method.

I might also have created a browser view which has this method, but i was not sure how to call that from a script, and curious if external methods still work in Plone 3. They do. I can now convert a title to an id in my script by doing
id = context.convertTitleToId(title)

Monday, November 10, 2008

Testing form input type in restricted python

My python controller script (.cpy), which should parse input from a form (.cpt), gets a parameter my_param which could be a single string or a list of strings. (If it's a single item, i want it converted to a list, because i'm going to loop over a list of items.)
However, "from types import type, ListType" is not available in a simple script. Luckily, we have something else: same_type

if not same_type(my_param,[]):
my_param = [my_param,]

Wednesday, November 5, 2008

AttributeError: 'module' object has no attribute 'Surrogate'

My Zope 2.9.9 instance wouldn't start, and failed with the message in the title. The hint in proved to be useful: after removing the zope 3 interface egg-info and the entire zope directory from /usr/lib/python2.4/site-packages, things are back to normal.

My guess is that this was installed after my upgrade to Ubuntu 8.10. For some reason, i had a package called python-zopeinterface installed.

Tuesday, November 4, 2008

Timeout during installation of new product

Today, while installing a new product on a production site with a large catalog, my connection timed out. This seems to be due to Plone re-cataloging all objects in the site. I know of two solutions:

  • Before installing, move profiles/default/catalog.xml to disabled_catalog.xml. Move it back after installing, and run the generic setup profile through the ZMI. (See also for another catalog installation issue.)

  • Patch to remove the updateRoleMappings step, like so:
    def dummyUpdateRoleMappings(context):
    """do nothing..."""

    updateRoleMappings = dummyUpdateRoleMappings

Sunday, November 2, 2008

Fast user switch on Intrepid using fglrx

Yesterday, I dist-upgraded our home computer to Ubuntu 8.10. The installed graphics driver (radeonhd, i believe) did not work with our ATI Radeon HD 2350: I got a blank screen. Setting the driver to 'vesa' did work.

After a user switch however, the colors would be messed up. This happens when using the "fast switch user" option, not when logging out and loggin in as someone else. Fast user switching is very convenient when I am playing music on Amarok, and H. wants to read her e-mail. There's plenty of literature on messed-up colors at launchpad.

So i went looking for the right driver. It seems that 'radeon' is the one that should work, but for some reason it doesn't. After trying the drivers 'ati', 'radeon' and 'radeonhd' with varying xorg.conf files, i finally installed the proprietary 'fglrx' driver, which worked.