source: WAeUP_SRP/trunk/skins/waeup_default/waeup_edit_ajax.py @ 2017

Last change on this file since 2017 was 2017, checked in by joachim, 17 years ago

started ajaxifying

  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
1##parameters=REQUEST, cluster=None
2# $Id: waeup_edit_ajax.py 2017 2007-07-16 12:32:00Z joachim $
3"""
4Called when a document form is posted for AJAX validation.
5
6Returns the validation result and the rendered page in an XML-RPC response.
7"""
8from Products.CPSDocument.utils import cleanAjaxParams
9
10# cleaning incoming params
11cleanAjaxParams(REQUEST)
12
13doc = context.getContent()
14res = doc.renderEditDetailed(request=REQUEST, proxy=context, cluster=cluster)
15layout, is_valid = str(res[0]), res[1]
16
17# AJAX tries to change the doc and just needs to know if there were errors
18# for feedback without a new form rendering.
19# XXX TODO: avoid here an extra HTML rendering
20# by calling renderEditDetailed() with the right parameters
21
22# At this time we do XML-RPC answers.
23# We'll see later how to automate it to avoid a manual serialization here.
24#from Products.zdb import set_trace
25#set_trace()
26
27if is_valid:
28    comments = REQUEST.get('comments')
29    context.cpsdocument_notify_modification(comments=comments)
30
31if is_valid and 'cpsdocument_edit_and_view_button' in REQUEST:
32    action = 'view'
33else:
34    action = ''
35
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.