[reledit] add ajax html head div, which allows to get additional css/js up to the browser #620569 stable
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Tue, 02 Mar 2010 11:21:29 +0100
branchstable
changeset 4739 64806b0f7431
parent 4738 6cca4f602486
child 4740 fee30ae3bc08
[reledit] add ajax html head div, which allows to get additional css/js up to the browser #620569
web/views/basecontrollers.py
--- a/web/views/basecontrollers.py	Mon Mar 01 16:02:22 2010 +0100
+++ b/web/views/basecontrollers.py	Tue Mar 02 11:21:29 2010 +0100
@@ -402,13 +402,23 @@
 
     @xhtmlize
     def js_reledit_form(self):
+        req = self._cw
         args = dict((x, self._cw.form[x])
                     for x in frozenset(('rtype', 'role', 'reload', 'landing_zone')))
         entity = self._cw.entity_from_eid(int(self._cw.form['eid']))
         # note: default is reserved in js land
         args['default'] = self._cw.form['default_value']
         args['reload'] = simplejson.loads(args['reload'])
-        return entity.view('doreledit', **args)
+        rset = req.eid_rset(int(self._cw.form['eid']))
+        view = req.vreg['views'].select('doreledit', req, rset=rset, rtype=args['rtype'])
+        stream = view.set_stream()
+        view.render(**args)
+        extresources = req.html_headers.getvalue(skiphead=True)
+        if extresources:
+            stream.write(u'<div class="ajaxHtmlHead">\n')
+            stream.write(extresources)
+            stream.write(u'</div>\n')
+        return stream.getvalue()
 
     @jsonize
     def js_i18n(self, msgids):