Integrating with kupu

by Martin Aspeli last modified Dec 30, 2008 03:03 PM
How to ensure smooth co-operation with kupu, Plone's new default visual editor

Plone 2.1 ships with kupu as the standard visual content editor. Kupu uses the concept of "drawers" that manage "resource types" for letting the user insert links, images, etc. In order for RichDocument users to be able to link to 'FileAttachment' and 'ImageAttachment' objects created inside the document, kupu must know that these are linkable types.

This is set in the 'kupu_library_tool', under the 'resource types' tab. Specifically, we add 'ImageAttachment' and 'FileAttachment' as 'linkable' resources, whilst 'ImageAttachment' is a 'mediaobject' alongside 'ATImage'. This is all configured in 'Install.py'::

kupuTool = getToolByName(self, 'kupu_library_tool')
linkable = list(kupuTool.getPortalTypesForResourceType('linkable'))
mediaobject = list(kupuTool.getPortalTypesForResourceType('mediaobject'))
if 'FileAttachment' not in linkable:
linkable.append('FileAttachment')
if 'ImageAttachment' not in linkable:
linkable.append('ImageAttachment')
if 'ImageAttachment' not in mediaobject:
mediaobject.append('ImageAttachment')
# kupu_library_tool has an idiotic interface, basically written purely to
# work with its configuration page. :-(
kupuTool.updateResourceTypes(({'resource_type' : 'linkable',
'old_type' : 'linkable',
'portal_types' : linkable},
{'resource_type' : 'mediaobject',
'old_type' : 'mediaobject',
'portal_types' : mediaobject},))

The last standard resource type is 'collection'. These items which kupu will treat as folders when navigating through drawers. We do not register RichDocument as a folder, obviously.