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

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

ajaxifying finished works for personal_edit

  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
1##parameters=REQUEST, cluster=None
2# $Id: waeup_edit_ajax.py 2020 2007-07-16 14:17:45Z 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# from Products.zdb import set_trace
13# set_trace()
14
15doc = context.getContent()
16res = doc.renderEditDetailed(request=REQUEST, proxy=context, cluster=cluster)
17layout, is_valid = str(res[0]), res[1]
18
19# AJAX tries to change the doc and just needs to know if there were errors
20# for feedback without a new form rendering.
21# XXX TODO: avoid here an extra HTML rendering
22# by calling renderEditDetailed() with the right parameters
23
24# At this time we do XML-RPC answers.
25# We'll see later how to automate it to avoid a manual serialization here.
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.