Ticket #12769 (closed Bug: duplicate)
PropertyValueError while setMemberProperties without checking the property's type
|Reported by:||mekell||Owned by:|
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.
A simple workaround could be as follows
@@ -272,8 +272,12 @@
if not sheet.hasProperty(k):
- sheet.setProperty(user, k, v)
- modified = True
+ try: + sheet.validateProperty(k, v) + sheet.setProperty(user, k, v) + modified = True + except PropertyValueError: + pass
break #raise RuntimeError, ("Mutable property provider "
- Status changed from new to confirmed
- Keywords PAS added; PlonePASmemberdatasetMemberProperties removed
- Version 4.1 deleted
- Component changed from Unknown to Backend (Python)