Skip to content

Cannot add a simple table due to z3c.form decoding request items #2

danjacka opened this Issue May 27, 2012 · 3 comments

2 participants

Plone Collective member

I wish I was posting a pull request rather than an issue, but the only solution I've found is a hack.

Steps to reproduce:

  • Build with
  • Add a new Plone site with collective.table installed.
  • Add new ... -> Table. On the add form, fill in the title (e.g. 'Test')
  • Locally stored data source is the only option, and is selected. Hit 'click here to configure it'. In the popup form, enter two column names, one per line (e.g. 'One' and 'Two')
  • Hit 'Save' at the bottom of the add form.

You'll see a validation error and a message to "Please correct the indicated errors". You cannot get past this point. I've tried this with multiple Plone, OS and browser configurations.

I've investigated and found the cause to be as described in See davisagli's answer. When you save the Archetypes form, the z3c.form popup has converted the items from string to unicode.

A dirty hack in process_form in gets things working. I change:



form_shadow = form.copy()
for k, v in form.items():
    del k
for k, v in form_shadow.items():
    form[k] = v

With all the form items restored to their string values, the table saves successfully.

I've tried to find the 'right' way to do this but came up short. Any ideas?

Plone Collective member

I think your workaround may be the best that we can do, given that z3c.form expects the inputs to be decoded but Archetypes doesn't. (It's a pretty unusual thing to need to process both types of form input in one request.)

You can write it a bit more concisely:

form_shadow = form.copy()
Plone Collective member

Added David's version of this workaround to

Plone Collective member
danjacka commented Jun 5, 2012

Pull request merged

@danjacka danjacka closed this Jun 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.