The incident of the missing form script

The incident of the missing form script, another Plone mystery.

Symptoms

While developing a series of forms using CMFFormController, suddenly one of the components couldn't be found.

To recap (and serve as an example to those neophytes), CMFFormController structures your forms as a series of form templates or scripts with metadata files determining how execution moves between them. In this case enterdata.cpt presents the page template for the form to be filled in and enterdata.cpt.metadata determines how it is processed on submission:

[default]
title = Risks Survey Data Entry
[validators]
validators = enterdata_validate
[actions]
action.success = traverse_to: string: enterdata_doit
action.failure = traverse_to: string: enterdata

That is, if validated by the enterdata_validate script, pass execution to enterdata_doit, otherwise return to the original template. But enterdata_doit couldn't be found:

This site encountered an error trying to fulfill your request.
The errors were:
Error Type ValueError Error Value Unable to find enterdata
Request made at 2007/01/23 13:26:22.167 GMT

Solution

I checked the spelling.

I checked that the templates and scripts were all appearing in the skin.

I returned to other templates that had previously been working and checked them. They weren't working now.

What was going on? I hadn't changed anything. Except I had. Something so small that I hadn't thought that it would make a difference. In the form metadata file, I'd tidied up the actions by inserting a few spaces. And the string directive - in this context at least - doesn't like a space between it and its argument. To wit, this works:

action.success = traverse_to: string:enterdata

This doesn’t:

action.success = traverse_to: string: enterdata