[reledit, autoform] move reledit_form definition in reledit.py
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Wed, 22 Feb 2012 09:31:54 +0100
changeset 8253 df7d6c57a6c8
parent 8251 df46bf02b107
child 8258 88a7d2c49d39
child 8574 268bc595271b
[reledit, autoform] move reledit_form definition in reledit.py No deprecation handling needed, reledit_form is new in CW 3.15
web/views/autoform.py
web/views/reledit.py
--- a/web/views/autoform.py	Mon Feb 20 16:13:36 2012 +0100
+++ b/web/views/autoform.py	Wed Feb 22 09:31:54 2012 +0100
@@ -134,7 +134,7 @@
 from cubicweb.predicates import (
     match_kwargs, match_form_params, non_final_entity,
     specified_etype_implements)
-from cubicweb.utils import json, json_dumps
+from cubicweb.utils import json_dumps
 from cubicweb.web import (stdmsgs, uicfg, eid_param,
                           form as f, formwidgets as fw, formfields as ff)
 from cubicweb.web.views import forms
@@ -460,19 +460,6 @@
     """
     self._cw.cancel_edition(errorurl)
 
-@ajaxfunc(output_type='xhtml')
-def reledit_form(self):
-    req = self._cw
-    args = dict((x, req.form[x])
-                for x in ('formid', 'rtype', 'role', 'reload', 'action'))
-    rset = req.eid_rset(typed_eid(self._cw.form['eid']))
-    try:
-        args['reload'] = json.loads(args['reload'])
-    except ValueError: # not true/false, an absolute url
-        assert args['reload'].startswith('http')
-    view = req.vreg['views'].select('reledit', req, rset=rset, rtype=args['rtype'])
-    return self._call_view(view, **args)
-
 
 def _add_pending(req, eidfrom, rel, eidto, kind):
     key = 'pending_%s' % kind
--- a/web/views/reledit.py	Mon Feb 20 16:13:36 2012 +0100
+++ b/web/views/reledit.py	Wed Feb 22 09:31:54 2012 +0100
@@ -29,14 +29,15 @@
 from logilab.common.deprecation import deprecated, class_renamed
 from logilab.common.decorators import cached
 
-from cubicweb import neg_role
+from cubicweb import neg_role, typed_eid
 from cubicweb.schema import display_name
-from cubicweb.utils import json_dumps
+from cubicweb.utils import json, json_dumps
 from cubicweb.predicates import non_final_entity, match_kwargs
 from cubicweb.view import EntityView
 from cubicweb.web import uicfg, stdmsgs
 from cubicweb.web.form import FieldNotFound
 from cubicweb.web.formwidgets import Button, SubmitButton
+from cubicweb.web.views.ajaxcontroller import ajaxfunc
 
 class _DummyForm(object):
     __slots__ = ('event_args',)
@@ -394,3 +395,18 @@
 
 
 ClickAndEditFormView = class_renamed('ClickAndEditFormView', AutoClickAndEditFormView)
+
+
+@ajaxfunc(output_type='xhtml')
+def reledit_form(self):
+    req = self._cw
+    args = dict((x, req.form[x])
+                for x in ('formid', 'rtype', 'role', 'reload', 'action'))
+    rset = req.eid_rset(typed_eid(self._cw.form['eid']))
+    try:
+        args['reload'] = json.loads(args['reload'])
+    except ValueError: # not true/false, an absolute url
+        assert args['reload'].startswith('http')
+    view = req.vreg['views'].select('reledit', req, rset=rset, rtype=args['rtype'])
+    return self._call_view(view, **args)
+