Wednesday, October 29, 2008

Special characters in VDEX vocabularies?

If this title is a question, the answer must be "no". I had modified the VDEX vocabularies in my product 'coachlink', and installing them resulted in an ExpatError:

Module , line 6, in _facade
Module AccessControl.requestmethod, line 64, in _curried
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 643, in reinstallProducts
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 584, in installProducts
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 521, in installProduct
- __traceback_info__: ('coachlink',)
Module Products.GenericSetup.tool, line 390, in runAllImportStepsFromProfile
- __traceback_info__: profile-Products.coachlink:default
Module Products.GenericSetup.tool, line 1182, in _runImportStepsFromContext
Module Products.GenericSetup.tool, line 1093, in _doRunImportStep
- __traceback_info__: coachlink-Install-Vocabularies
Module Products.coachlink.setuphandlers, line 92, in installVocabularies
Module Products.ATVocabularyManager.types.vdex.vocabulary, line 274, in importXMLBinding
Module xml.dom.minidom, line 1925, in parseString
Module xml.dom.expatbuilder, line 940, in parseString
Module xml.dom.expatbuilder, line 223, in parseString
ExpatError: undefined entity: line 34, column 40

One of the changes was putting an ‘ instead of ‘ somewhere, so that was a clue... Removing everything that began with & from the vocabulary helped.

Monday, October 27, 2008

Query portal catalog by interface: object_provides

Edit 2010-05-19: This is now a how-to on

Suppose you have several types (for example, event types like 'Birthday','Wedding','Graduation') in your portal which implement the same interface (for example, IIsCauseForCelebration), and you want to get items of these types from the catalog.
Rather than name the types explicitly (like portal_type=['Birthday','Wedding','Graduation' ]) you may query the wanted interface:

from import IIsCauseForCelebration

This has the additional advantage that if products added or modified later add types which implement the interface, these new types will also show up in your query.

Wednesday, October 22, 2008

How to pretty-print an "ugly HTML" document

Using Python and the BeautifulSoup module:

from BeautifulSoup import BeautifulSoup
html = '' # insert UHTML here
print soup.prettify()

Monday, October 20, 2008

default_method for ReferenceField?

Trying to set a default value (via the default_method tagged value in UML) on a reference field, and wondering why it didn't work, i ran into this discussion, and i found this post in the plone issue tracker, marking it as a requested enhancement. It seems that setting a default method for a ReferenceField not yet possible.

Monday, October 13, 2008

Why does user.hasRole('Manager') always return True?

I wouldn't know, but this may be a clue.

Bottom line: If you want to check for a user's roles from TAL, use "user.has_role()", not "user.hasRole()".

user.has_role(['Owner','Editor',], context)
checks for roles on current context.

Wednesday, October 8, 2008

Stand Eredivisie

Friday, October 3, 2008

Indexing files in Plone 3

Why doesn't Plone index my pdf/doc/xls attachments, or why aren't they shown in the search results?
Possible reasons (in random order):

  • Because file conversion tools aren't available on the command line. For a list of required converters, see

  • Because the file transform isn't registered in Portal Transforms. To add a pdf to text converter: Go to portal_transforms, click 'Add' (Transform), give it an id of 'pdf_to_text' and Module 'Products.PortalTransforms.transforms.pdf_to_text'. This step may be required when converters weren't available on the system during the Zope installation.

  • Because the "File" type was disabled in @@search-controlpanel