manage_changeProperties() and manage_addProperty() behave differently for "lines"

Bug #143516 reported by Berthold Stöger
2
Affects Status Importance Assigned to Milestone
Zope 2
Invalid
Low
Unassigned

Bug Description

For "lines"-properties manage_addProperty() casts an array of ints to an array of strings, whereas manage_changeProperties() does not. This is against the principle of least surprises.

This PythonScript:
"""
 ## Script (Python) "testbug"
 ##bind container=container
 ##bind context=context
 ##bind namespace=
 ##bind script=script
 ##bind subpath=traverse_subpath
 ##parameters=
 ##title=
 ##
 def is_int(i):
   try:
     i + 1
     return "is int"
   except:
     return "isn't int"

 try: obj.manage_delProperties(ids=('testproperty',))
 except: pass

 obj = script
 print "Add property..."
 obj.manage_addProperty('testproperty', [1,2,3], 'lines')
 for i in obj.testproperty: print is_int(i)

 print "Change property..."
 obj.manage_changeProperties(testproperty=[1,2,3])
 for i in obj.testproperty: print is_int(i)

 return printed
"""
returns
"""
 Add property...
 isn't int
 isn't int
 isn't int
 Change property...
 is int
 is int
 is int
"""
which is not what one would expect.

Tags: bug zope
Revision history for this message
Andreas Jung (ajung) wrote :

Status: Pending => Wontfix

Type converters only deal with the outer type but not with the types of contained elements. This should be handled on the application level.

Revision history for this message
Tres Seaver (tseaver) wrote :

Touch this issue to get its transcript mailed out after today's
mailhost failures.

Revision history for this message
Florent Guillaume (efge) wrote :

Status: Wontfix => Pending

This doesn't explain the difference of behaviour between the two methods.
Reopening.
See http://mail.zope.org/pipermail/zope/2006-June/166882.html

Changed in zope2:
status: New → Confirmed
Revision history for this message
Jens Vagelpohl (dataflake-deactivatedaccount-deactivatedaccount) wrote :

The type converter in question (ZPublisher.Converters.field2lines) does indeed touch the contained elements and converts them to strings. However, the behavior has existed for over 11 years now. I'm questioning the wisdom of changing it now and potentially breaking existing applications.

Revision history for this message
Colin Watson (cjwatson) wrote :

The zope2 project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/zope2.

Changed in zope2:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.