manage_edit fails on DTMLDocument
Bug #142590 reported by
Drew Ferguson
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 2 |
Fix Released
|
Medium
|
Unassigned |
Bug Description
Uploaded: zopebug.
Changed in zope2: | |
status: | New → Confirmed |
Changed in zope2: | |
assignee: | nobody → Jens Vagelpohl (jens-dataflake) |
Changed in zope2: | |
milestone: | none → 2.12.7 |
Changed in zope2: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
Calling manage_edit on a DTMLDocument sometimes barfs with
Traceback (innermost last): e.DT_String, line 474, in __call__ e.DT_Util, line 201, in eval DC.Scripts. Bindings, line 252, in __call__ DC.Scripts. Bindings, line 283, in _bindAndExec PythonScripts. PythonScript, line 315, in _exec TaintedString, line 89, in __getattr__
Module ZPublisher.Publish, line 98, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 39, in call_object
Module OFS.DTMLMethod, line 126, in __call__
Module DocumentTemplat
Module DocumentTemplat
- __traceback_info__: setBodyContents
Module <string>, line 2, in f
Module Shared.
Module Shared.
Module Products.
Module Script (Python), line 11, in setBodyContents
- <PythonScript at /PF/setBodyContents used for /PF/news>
- Line 11
Module OFS.DTMLDocument, line 77, in manage_edit
Module ZPublisher.
AttributeError: read
For instance, from a python script
bodyStr = string.replace( bodyStr, '\015\012\015\012', '<br>\015\ 012<br> \015\012' ) 'body_contents' ].manage_ edit( data=bodyStr, title='Body Contents' )
context[
For plain text, the call is fine - if the text contains markup, it fails
Relevant line (77) in DTMLDocumemt.py is
if type(data) is not type(''): data=data.read()
For data containing markup, type(data) is resolving as <type instance> which presumably has no attribute read.
Workaround is to coerce the variable to a string with
context[ 'body_contents' ].manage_ edit( data=str(bodyStr), title='Body Contents' )