web/views/basecontrollers.py
changeset 2557 200985d3258d
parent 2555 ca7b122f34fa
child 2559 46859078c866
equal deleted inserted replaced
2556:4608d259c3db 2557:200985d3258d
   219 
   219 
   220 
   220 
   221 class FormValidatorController(Controller):
   221 class FormValidatorController(Controller):
   222     id = 'validateform'
   222     id = 'validateform'
   223 
   223 
       
   224     def response(self, domid, status, args):
       
   225         self.req.set_content_type('text/html')
       
   226         jsargs = simplejson.dumps( (status, args) )
       
   227         return """<script type="text/javascript">
       
   228  window.parent.handleFormValidationResponse('%s', null, null, %s);
       
   229 </script>""" %  (domid, jsargs)
       
   230 
   224     def publish(self, rset=None):
   231     def publish(self, rset=None):
   225         self.req.json_request = True
   232         self.req.json_request = True
   226         # XXX unclear why we have a separated controller here vs
   233         # XXX unclear why we have a separated controller here vs
   227         # js_validate_form on the json controller
   234         # js_validate_form on the json controller
   228         status, args = _validate_form(self.req, self.vreg)
   235         status, args = _validate_form(self.req, self.vreg)
   229         self.req.set_content_type('text/html')
       
   230         jsarg = simplejson.dumps( (status, args) )
       
   231         domid = self.req.form.get('__domid', 'entityForm').encode(
   236         domid = self.req.form.get('__domid', 'entityForm').encode(
   232             self.req.encoding)
   237             self.req.encoding)
   233         return """<script type="text/javascript">
   238         return self.response(domid, status, args)
   234  window.parent.handleFormValidationResponse('%s', null, null, %s);
       
   235 </script>""" %  (domid, simplejson.dumps( (status, args) ))
       
   236 
   239 
   237 
   240 
   238 class JSonController(Controller):
   241 class JSonController(Controller):
   239     id = 'json'
   242     id = 'json'
   240 
   243