Commit 3fc0004f authored by Jérome Perrin's avatar Jérome Perrin

ZODB Components: add getContentType method

This is mostly for editor fields, to fix the problem that components were
edited by the text editor and not the code editor.

Editor is selected by Base_getEditorFieldPreferredTextEditor, which will
use a text editor by default, unless the document has a content type, in
which case it will return the most appropriate editor, which is by default
the source code editor for documents whose text content is not text/html.

It's anyway not wrong to have a content type defined here, Components
are TextDocuments and TextDocuments usually have getContentType method.
parent f084c646
......@@ -15,12 +15,12 @@
<tr><td>assertTextPresent</td>
<td>Reset Successfully.</td><td></td></tr>
<tr><td colspan="3"><b>Set preferred text editor</b></td></tr>
<tr><td colspan="3"><b>Set preferred code editor</b></td></tr>
<tr><td>open</td>
<td>${base_url}/portal_preferences/erp5_ui_test_preference/Preference_viewHtmlStyle</td><td></td></tr>
<tr><td>click</td>
<td>//input[@name="field_my_preferred_text_editor" and @value="monaco"]</td><td></td></tr>
<td>//input[@name="field_my_preferred_source_code_editor" and @value="monaco"]</td><td></td></tr>
<tr><td>clickAndWait</td>
<td>//button[@name='Base_edit:method']</td><td></td></tr>
......
......@@ -218,6 +218,13 @@ class ComponentMixin(PropertyRecordableMixin, Base):
except (AttributeError, KeyError, IndexError):
return 'draft'
security.declareProtected(Permissions.AccessContentsInformation,
'getContentType')
def getContentType(self, default=None):
"""Returns the text content.
"""
return "text/x-python"
security.declareProtected(Permissions.ModifyPortalContent, 'checkConsistency')
def checkConsistency(self, *args, **kw):
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment