--- 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)