Back to index

plone3  3.1.7
document_edit_control.py
Go to the documentation of this file.
00001 ##parameters=text_format, text, SafetyBelt='', **kw
00002 ##
00003 from Products.CMFDefault.exceptions import EditingConflict
00004 from Products.CMFDefault.exceptions import ResourceLockedError
00005 from Products.CMFDefault.utils import Message as _
00006 
00007 if text_format != context.text_format or text != context.EditableBody():
00008     try:
00009         context.edit(text_format, text, safety_belt=SafetyBelt)
00010         return context.setStatus(True, _(u'Document changed.'))
00011     except (ResourceLockedError, EditingConflict), errmsg:
00012         return context.setStatus(False, errmsg)
00013 else:
00014     return context.setStatus(False, _(u'Nothing to change.'))