Back to index

plone3  3.1.7
document_edit_form.py
Go to the documentation of this file.
00001 ##parameters=change='', change_and_view=''
00002 ##
00003 from Products.CMFDefault.utils import decode
00004 from Products.CMFDefault.utils import html_marshal
00005 from Products.CMFDefault.utils import Message as _
00006 
00007 form = context.REQUEST.form
00008 if change and \
00009         context.validateTextFile(**form) and \
00010         context.validateHTML(**form) and \
00011         context.document_edit_control(**form) and \
00012         context.setRedirect(context, 'object/edit'):
00013     return
00014 elif change_and_view and \
00015         context.validateTextFile(**form) and \
00016         context.validateHTML(**form) and \
00017         context.document_edit_control(**form) and \
00018         context.setRedirect(context, 'object/view'):
00019     return
00020 
00021 
00022 options = {}
00023 
00024 options['title'] = context.Title()
00025 options['description'] = context.Description()
00026 options['text_format'] = form.get('text_format', context.text_format)
00027 options['text'] = form.get('text', context.EditableBody())
00028 
00029 SafetyBelt = form.get('SafetyBelt', context.SafetyBelt())
00030 hidden_vars = [ {'name': n, 'value': v}
00031                 for n, v in html_marshal(SafetyBelt=SafetyBelt) ]
00032 buttons = []
00033 target = context.getActionInfo('object/edit')['url']
00034 buttons.append( {'name': 'change', 'value': _(u'Change')} )
00035 buttons.append( {'name': 'change_and_view', 'value': _(u'Change and View')} )
00036 options['form'] = { 'action': target,
00037                     'listHiddenVarInfos': tuple(hidden_vars),
00038                     'listButtonInfos': tuple(buttons) }
00039 
00040 return context.document_edit_template(**decode(options, script))