Calling manage_edit on a DTMLDocument sometimes barfs with
Traceback (innermost last):
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 DocumentTemplate.DT_String, line 474, in __call__
Module DocumentTemplate.DT_Util, line 201, in eval
- __traceback_info__: setBodyContents
Module <string>, line 2, in f
Module Shared.DC.Scripts.Bindings, line 252, in __call__
Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec
Module Products.PythonScripts.PythonScript, line 315, in _exec
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.TaintedString, line 89, in __getattr__
AttributeError: read
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' )