Ticket #2211 (closed defect: fixed)

Opened 9 years ago

Last modified 9 years ago

New properties import error

Reported by: gracinet Owned by: gracinet
Priority: P1 Milestone: CPS 3.5.1
Component: CPS (global) Version: 3.5.1rc2
Severity: major Keywords:
Cc:

Description

After a code upgrade providing a new property for some class, one can get an error trying to set the property value in a profile.

End of traceback:

  Module Products.CMFCore.exportimport.typeinfo, line 274, in importTypesTool
  Module Products.GenericSetup.utils, line 758, in importObjects
   - __traceback_info__: portal_types
  Module Products.GenericSetup.utils, line 754, in importObjects
   - __traceback_info__: types/Recording
  Module Products.GenericSetup.utils, line 515, in _importBody
  Module Products.CMFCore.exportimport.typeinfo, line 64, in _importNode
  Module Products.CPSCore.PatchPropertyManager, line 61, in _initProperties
ValueError: undefined property 'auto_content_types'

(got it trying to apply #2205 on some custom project)

This happens actually for instances of said class that themselves have some other additional property (added in ZMI or through GenericSetup profiles) only.

Explanation: in the code adding a property like auto_content_types is done by changing the class level _properties attribute.

But if a new property (say, my_prop) has been added to some instance of that class, its _properties attribute has become independent from the class level. In other words, the instance does not "know" about auto_content_types. I suspect the new property not to be available in ZMI either.

One can try as a workaround to force the property creation on the instance as if it were an instance specific one by specifying the type, as in:

  <property name="auto_content_types" type="lines">

but one still gets an error:

  Module Products.CMFCore.exportimport.typeinfo, line 64, in _importNode
  Module Products.CPSCore.PatchPropertyManager, line 56, in _initProperties
  Module OFS.PropertyManager, line 189, in _setProperty
BadRequest: Invalid or duplicate property id

This time, that's because there's a class level attribute providing a default value (this is mandatory), and the property creation process triggered by the types XML attribute checks that to avoid creation of existing properties.

It turns out that all of this happens within CPSCore's PatchPropertyManager.py. A simple solution is to upgrade the _properties dict of instances in the import process beforehand. But that doesn't fix ZMI, and the patched GenericSetup code (or even OFS.PropertyManager) should be checked to see if still has the problem.

This has been hanging probably for a long time. It's obviously not so common, but can be blocking for specific projects or long instances with lots of history.

Change History

comment:1 Changed 9 years ago by gracinet

Quick fix as explained above done (default branch, remerged in 3.5.2)

There's also an obvious optimization that could be done, but a bit risky, and hard to tell whether that's really significant.

comment:2 Changed 9 years ago by gracinet

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.