source: WAeUP_SRP/branches/joachim-azax-branch/skins/waeup_custom/cpsdocument_edit.py @ 16161

Last change on this file since 16161 was 1164, checked in by Henrik Bettermann, 18 years ago

getStudentInfo replaced or removed

  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1## Script (Python) "cpsdocument_edit"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=REQUEST, cluster=None, cpsdocument_edit_and_view_button=None, action=None
8##title=
9##
10# $Id: cpsdocument_edit.py 1164 2006-12-31 10:32:05Z henrik $
11"""
12Called when a document form is posted.
13
14Validates data, then:
15
16 - if there's no error, updates the object and redirects to it,
17
18 - if there's an error, puts data in session and redirects to edit form.
19
20A form uid is propagated during the redirect to uniquely identify the
21form in the session.
22"""
23
24from urllib import urlencode
25from Products.CPSDocument.utils import getFormUidUrlArg
26
27# Until ajax posts directly to its own script...
28if 'ajax_edit' in REQUEST.form:
29    return context.cpsdocument_edit_ajax(REQUEST, cluster=cluster)
30
31# Check flexible controls
32context.editLayouts(REQUEST=REQUEST)
33
34# Validate the document and write it if it's valid
35# (We don't call getEditableContent here, validate does it when needed.)
36doc = context.getContent()
37is_valid, ds = doc.validate(request=REQUEST, proxy=context, cluster=cluster,
38                            use_session=True)
39args = {}
40
41if action is None:
42    ti = doc.getTypeInfo()
43    action = ti.queryMethodID('edit', 'cpsdocument_edit_form')
44    action = '/' + action
45
46if is_valid:
47    comments = REQUEST.get('comments')
48    context.cpsdocument_notify_modification(comments=comments)
49    if cpsdocument_edit_and_view_button is not None:
50        action = ''
51    psm = 'psm_content_changed'
52
53else:
54    psm = 'psm_content_error'
55    args = getFormUidUrlArg(REQUEST)
56if psm:
57    args['portal_status_message'] = psm
58url = context.absolute_url() + action + '?' + urlencode(args)
59REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.