[859] | 1 | ##parameters=REQUEST, cluster=None, cpsdocument_edit_and_view_button=None, came_from=None |
---|
| 2 | # $Id: external_edit.py 805 2006-11-09 09:38:29Z joachim $ |
---|
| 3 | """ |
---|
| 4 | Called when a document form is posted. |
---|
| 5 | |
---|
| 6 | Validates data, then: |
---|
| 7 | |
---|
| 8 | - if there's no error, updates the object and redirects to it, |
---|
| 9 | |
---|
| 10 | - if there's an error, puts data in session and redirects to edit form. |
---|
| 11 | |
---|
| 12 | A form uid is propagated during the redirect to uniquely identify the |
---|
| 13 | form in the session. |
---|
| 14 | """ |
---|
| 15 | |
---|
| 16 | from urllib import urlencode |
---|
| 17 | from Products.CPSDocument.utils import getFormUidUrlArg |
---|
| 18 | |
---|
| 19 | # Check flexible controls |
---|
| 20 | #context.editLayouts(REQUEST=REQUEST) |
---|
| 21 | |
---|
| 22 | # Validate the document and write it if it's valid |
---|
| 23 | # (We don't call getEditableContent here, validate does it when needed.) |
---|
| 24 | doc = context.getContent() |
---|
| 25 | is_valid, ds = doc.validate(request=REQUEST, proxy=context, cluster=cluster, |
---|
| 26 | use_session=True) |
---|
| 27 | |
---|
| 28 | ##if action is None: |
---|
| 29 | ## ti = doc.getTypeInfo() |
---|
| 30 | ## action = ti.queryMethodID('edit', 'external_edit_form') |
---|
| 31 | ## action = '/' + action |
---|
| 32 | |
---|
| 33 | action = "/" + came_from |
---|
| 34 | |
---|
| 35 | if is_valid: |
---|
| 36 | comments = REQUEST.get('comments') |
---|
| 37 | context.cpsdocument_notify_modification(comments=comments) |
---|
| 38 | if cpsdocument_edit_and_view_button is not None: |
---|
| 39 | action = '' |
---|
| 40 | psm = 'psm_content_changed' |
---|
| 41 | args = {} |
---|
| 42 | else: |
---|
| 43 | psm = 'psm_content_error' |
---|
| 44 | args = getFormUidUrlArg(REQUEST) |
---|
| 45 | |
---|
| 46 | args['portal_status_message'] = psm |
---|
| 47 | url = context.absolute_url() + action + '?' + urlencode(args) |
---|
| 48 | REQUEST.RESPONSE.redirect(url) |
---|
| 49 | |
---|