fix vocab param to avoid deprecation warning stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 21 Sep 2009 18:02:48 +0200
branchstable
changeset 3347 428f95118556
parent 3346 b1fd9d4ef579
child 3348 97dca770c028
fix vocab param to avoid deprecation warning
schema.py
web/formfields.py
--- a/schema.py	Mon Sep 21 18:02:21 2009 +0200
+++ b/schema.py	Mon Sep 21 18:02:48 2009 +0200
@@ -958,9 +958,12 @@
 NEED_PERM_FORMATS = [_('text/cubicweb-page-template')]
 
 @monkeypatch(FormatConstraint)
-def vocabulary(self, entity=None, req=None):
-    if req is None and entity is not None:
+def vocabulary(self, entity=None, form=None):
+    req = None
+    if form is None and entity is not None:
         req = entity.req
+    elif form is not None:
+        req = form.req
     if req is not None and req.user.has_permission(PERM_USE_TEMPLATE_FORMAT):
         return self.regular_formats + tuple(NEED_PERM_FORMATS)
     return self.regular_formats
--- a/web/formfields.py	Mon Sep 21 18:02:21 2009 +0200
+++ b/web/formfields.py	Mon Sep 21 18:02:48 2009 +0200
@@ -283,7 +283,7 @@
                 # else we want a format selector
                 fkwargs['widget'] = Select()
                 fcstr = FormatConstraint()
-                fkwargs['choices'] = fcstr.vocabulary(req=req)
+                fkwargs['choices'] = fcstr.vocabulary(form=form)
                 fkwargs['internationalizable'] = True
                 fkwargs['initial'] = lambda f: f.form_field_format(self)
             field = StringField(name=self.name + '_format', **fkwargs)