Ticket #13119 (confirmed Bug)
PropertyValueError while setMemberProperties without checking the property's type
Reported by: | mekell | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 4.x |
Component: | General | Version: | 4.1 |
Keywords: | PAS | Cc: |
Description
When "setMemberProperties" of "MemberData" tries to set the properties, it sets the given property on ALL user's sheets providing IMutablePropertySheet.
There are some situations, where a user has more than one propertysheet with the same propertyId BUT with different types. IMHO those should be therefore considered as two different properties.
An example of such a situation is FacultyStaffDirectory. Here the user has two propertysheets: membrane_properties, and mutable_properties. Both propertysheets have a property with the same id='ext_editor' but of different types (boolean in mutable_properties, string in membrane_properties) When the property "ext_editor" is set via "Personal Preferences" (i.e. /Plone/personalize_form) it succeeds on "mutable_properties" but fails on "membrane_properties" because the value is of type boolean.
Because setMemberProperties do not check the type of the property it fails on setting the boolean value in "ext_editor:string". Actually checking the property is delegated to validateProperty, which unfortunately simply raises an exception.
To solve such situations, one could check the type before setting the property and only setting it in such propertysheets matching the id AND the type of the property.
It is the case in Plone 4.1.3 and 4.1.4
It affects setMemberProperties in memberdata.py at least since rev. 9639 (Apr 2005) up to rev. 228459.
I suggest following workaround:
Products.PlonePAS-4.0.11-py2.6.egg/Products/PlonePAS/tools/memberdata.py @@ -272,8 +272,12 @@ if not sheet.hasProperty(k): continue if IMutablePropertySheet.providedBy(sheet): - sheet.setProperty(user, k, v) - modified = True + try: + sheet.validateProperty(k, v) + sheet.setProperty(user, k, v) + modified = True + except PropertyValueError: + pass else: break #raise RuntimeError, ("Mutable property provider "