source: WAeUP_SRP/trunk/skins/waeup_academics/academics_edit_ajax.py @ 331

Last change on this file since 331 was 309, checked in by joachim, 18 years ago

=types changed

File size: 1.5 KB
Line 
1## Script (Python) "cpsdocument_edit_ajax"
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
8##title=
9##
10# $Id: cpsdocument_edit_ajax.py 45956 2006-05-26 15:14:03Z tziade $
11"""
12Called when a document form is posted for AJAX validation.
13
14Returns the validation result and the rendered page in an XML-RPC response.
15"""
16from Products.CPSDocument.utils import cleanAjaxParams
17
18# cleaning incoming params
19cleanAjaxParams(REQUEST)
20
21doc = context.getContent()
22res = doc.renderEditDetailed(request=REQUEST, proxy=context, cluster=cluster)
23layout, is_valid = str(res[0]), res[1]
24
25# AJAX tries to change the doc and just needs to know if there were errors
26# for feedback without a new form rendering.
27# XXX TODO: avoid here an extra HTML rendering
28# by calling renderEditDetailed() with the right parameters
29
30# At this time we do XML-RPC answers.
31# We'll see later how to automate it to avoid a manual serialization here.
32if is_valid and 'cpsdocument_edit_and_view_button' in REQUEST:
33    action = 'view'
34else:
35    action = ''
36
37REQUEST.RESPONSE.setHeader('Content-Type', 'text/xml')
38REQUEST.RESPONSE.setHeader('Cache-Control', 'no-cache')
39response = '<?xml version="1.0" encoding="utf-8" ?>'
40response += '<ajax-response>'
41response += '<result>%s</result>' % str(bool(is_valid))
42response += '<layout><![CDATA[%s]]></layout>' % layout
43response += '<action>%s</action>' % action
44response += '</ajax-response>'
45
46return response
Note: See TracBrowser for help on using the repository browser.