When I change the text, for example. in a document with setText()the document content type is changed to text/plain.
In [1]: app.Plone.invokeFactory('Document', 'doc')
Out[1]: 'doc'
In [2]: app.Plone.doc.getContentType()
Out[2]: 'text/html'
In [3]: app.Plone.doc.setText('xyz'); app.Plone.doc.getContentType()
Out[3]: 'text/plain'
In [4]: app.Plone.doc.setText('<abc>xyz</abc>'); app.Plone.doc.getContentType()
Out[4]: 'text/html'
Even if I create a document and I set it mimetypeexplicitly to text/plain, it changes the type to text/html.
In [1]: app.Plone.invokeFactory('Document', 'doc',
text='<abc>xyz</abc>',
mimetype='text/plain')
Out[1]: 'doc'
In [2]: app.Plone.doc.getContentType()
Out[2]: 'text/html'
The text is processed by the _process_input()class TextField(FileField), and it guesses the type and changes it.
Does the API expect the programmer to know all the guesswork _process_input()? If so, is it documented somewhere?
source
share