Ticket #2180 (closed defect: fixed)

Opened 9 years ago

Last modified 9 years ago

String fields should optionnaly accept None as a valid value

Reported by: gracinet Owned by: madarche
Priority: P2 Milestone: CPS 3.5.1
Component: CPS (global) Version: 3.5.1rc1
Severity: critical Keywords: file field none string validate
Cc:

Description

File fields can have severe problems originating in the newly hooked validation.

Fields validation has been hooked for #2178 right before the CPS-3.5.1-rc1 release. It was also a long lasting issue, these not being called.

As a result, String Fields don't accept the None value any more.

This had been taken into account in CPSForum before the release because it showed up in unit tests (forum post objects reference their parents with a String Field, that can be None to indicate that there's no parent).

Now the thing is that File Fields are meant to compute text and html alternatives through computeDependantFields (sic) and PortalTransforms. The text alternative is a String Field, and the computation system can produce None.

In turn this breaks any writing to through a field without a proper transform, including the upgrade step to unicode for documents.

Change History

comment:1 Changed 9 years ago by gracinet

Here's the end of traceback one gets through the upgrade step:

  Module Products.CPSDocument.upgrade, line 285, in upgrade_doc_unicode
  Module Products.CPSSchemas.DataModel, line 233, in __setitem__
  Module Products.CPSSchemas.BasicFields, line 245, in validate
ValidationError: Not a string: None

comment:2 Changed 9 years ago by gracinet

Should be fixed by the introduction of a new property on String Field to allow validation of None as a value.

All of this has been pushed to hg.cps-cms.org Keeping open while it's been tested

comment:3 Changed 9 years ago by gracinet

One needs to update the file schema (depends on the way a particular instance is supposed to be upgraded).

comment:4 Changed 9 years ago by gracinet

  • Status changed from new to closed
  • Resolution set to fixed

I've seen it working on 3 different applications, now, including one on a different field.

Note: See TracTickets for help on using tickets.