--- a/web/views/autoform.py Mon Dec 21 20:18:53 2009 +0100
+++ b/web/views/autoform.py Mon Dec 21 20:21:56 2009 +0100
@@ -112,7 +112,7 @@
return self.maxrelitems + 1
@property
- def form_needs_multipart(self):
+ def needs_multipart(self):
"""true if the form needs enctype=multipart/form-data"""
return self._subform_needs_multipart()
@@ -124,7 +124,7 @@
def _subform_needs_multipart(self, _tested=None):
if _tested is None:
_tested = set()
- if super(AutomaticEntityForm, self).form_needs_multipart:
+ if super(AutomaticEntityForm, self).needs_multipart:
return True
# take a look at inlined forms to check (recursively) if they
# need multipart handling.
@@ -142,7 +142,7 @@
if hasattr(formview.form, '_subform_needs_multipart'):
needs_multipart = formview.form._subform_needs_multipart(_tested)
else:
- needs_multipart = formview.form.form_needs_multipart
+ needs_multipart = formview.form.needs_multipart
if needs_multipart:
return True
return False
--- a/web/views/cwproperties.py Mon Dec 21 20:18:53 2009 +0100
+++ b/web/views/cwproperties.py Mon Dec 21 20:21:56 2009 +0100
@@ -196,8 +196,8 @@
path = self._cw.relative_path()
if '?' in path:
path, params = path.split('?', 1)
- form.form_add_hidden('__redirectparams', params)
- form.form_add_hidden('__redirectpath', path)
+ form.add_hidden('__redirectparams', params)
+ form.add_hidden('__redirectpath', path)
for key in keys:
self.form_row(form, key, splitlabel)
renderer = self._cw.vreg['formrenderers'].select('cwproperties', self._cw,
@@ -215,7 +215,7 @@
subform.append_field(PropertyValueField(name='value', label=label,
eidparam=True))
#subform.vreg = self._cw.vreg
- subform.form_add_hidden('pkey', key, eidparam=True)
+ subform.add_hidden('pkey', key, eidparam=True)
form.add_subform(subform)
return subform
@@ -253,7 +253,7 @@
# if user is in the managers group and the property is being created,
# we have to set for_user explicitly
if not subform.edited_entity.has_eid() and self.user.matching_groups('managers'):
- subform.form_add_hidden('for_user', self.user.eid, eidparam=True)
+ subform.add_hidden('for_user', self.user.eid, eidparam=True)
# cwproperty form objects ######################################################
--- a/web/views/editforms.py Mon Dec 21 20:18:53 2009 +0100
+++ b/web/views/editforms.py Mon Dec 21 20:21:56 2009 +0100
@@ -410,8 +410,8 @@
"""customize your form before rendering here"""
super(CopyFormView, self).init_form(form, entity)
if entity.eid == self.newentity.eid:
- form.form_add_hidden(eid_param('__cloned_eid', entity.eid),
- self.copying.eid)
+ form.add_hidden(eid_param('__cloned_eid', entity.eid),
+ self.copying.eid)
for rschema, role in form.editable_attributes():
if not rschema.final:
# ensure relation cache is filed
@@ -536,8 +536,8 @@
# * str(self.rtype) in case it's a schema object
# * neged_role() since role is the for parent entity, we want the role
# of the inlined entity
- form.form_add_hidden(name=str(self.rtype), value=self.peid,
- role=neg_role(self.role), eidparam=True, id=iid)
+ form.add_hidden(name=str(self.rtype), value=self.peid,
+ role=neg_role(self.role), eidparam=True, id=iid)
def keep_entity(self, form, entity):
if not entity.has_eid():
--- a/web/views/formrenderers.py Mon Dec 21 20:18:53 2009 +0100
+++ b/web/views/formrenderers.py Mon Dec 21 20:21:56 2009 +0100
@@ -146,7 +146,7 @@
return u''
def open_form(self, form, values):
- if form.form_needs_multipart:
+ if form.needs_multipart:
enctype = 'multipart/form-data'
else:
enctype = 'application/x-www-form-urlencoded'
--- a/web/views/forms.py Mon Dec 21 20:18:53 2009 +0100
+++ b/web/views/forms.py Mon Dec 21 20:21:56 2009 +0100
@@ -81,7 +81,7 @@
self.fields = list(self.__class__._fields_)
for key, val in kwargs.items():
if key in NAV_FORM_PARAMETERS:
- self.form_add_hidden(key, val)
+ self.add_hidden(key, val)
elif hasattr(self.__class__, key) and not key[0] == '_':
setattr(self, key, val)
else:
@@ -89,8 +89,8 @@
# skip other parameters, usually given for selection
# (else write a custom class to handle them)
if mainform:
- self.form_add_hidden('__errorurl', self.session_key())
- self.form_add_hidden('__domid', self.domid)
+ self.add_hidden('__errorurl', self.session_key())
+ self.add_hidden('__domid', self.domid)
self.restore_previous_post(self.session_key())
# XXX why do we need two different variables (mainform and copy_nav_params ?)
@@ -99,19 +99,18 @@
if not param in kwargs:
value = req.form.get(param)
if value:
- self.form_add_hidden(param, value)
+ self.add_hidden(param, value)
if submitmsg is not None:
- self.form_add_hidden('__message', submitmsg)
- self.context = None
+ self.add_hidden('__message', submitmsg)
if 'domid' in kwargs:# session key changed
self.restore_previous_post(self.session_key())
@property
- def form_needs_multipart(self):
+ def needs_multipart(self):
"""true if the form needs enctype=multipart/form-data"""
return any(field.needs_multipart for field in self.fields)
- def form_add_hidden(self, name, value=None, **kwargs):
+ def add_hidden(self, name, value=None, **kwargs):
"""add an hidden field to the form"""
kwargs.setdefault('widget', fwdgs.HiddenInput)
field = StringField(name=name, value=value, **kwargs)
@@ -135,13 +134,13 @@
"""
self.build_context(formvalues or {})
if renderer is None:
- renderer = self.form_default_renderer()
- return renderer.render(self, rendervalues or {})
+ renderer = self.default_renderer()
+ return renderer.render(self, kwargs)
- def form_default_renderer(self):
- return self._cw.vreg['formrenderers'].select(self.form_renderer_id,
- self._cw, rset=self.cw_rset,
- row=self.cw_row, col=self.cw_col)
+ def default_renderer(self):
+ return self._cw.vreg['formrenderers'].select(
+ self.form_renderer_id, self._cw,
+ rset=self.cw_rset, row=self.cw_row, col=self.cw_col)
formvalues = None
def build_context(self, formvalues=None):
@@ -171,7 +170,11 @@
"""
return self.form_valerror and field.name in self.form_valerror.errors
- @deprecated('use .render(formvalues, rendervalues)')
+ @deprecated('[3.6] use .add_hidden(name, value, **kwargs)')
+ def form_add_hidden(self, name, value=None, **kwargs):
+ return self.add_hidden(name, value, **kwargs)
+
+ @deprecated('[3.6] use .render(formvalues, **rendervalues)')
def form_render(self, **values):
"""render this form, using the renderer given in args or the default
FormRenderer()
@@ -197,20 +200,20 @@
super(EntityFieldsForm, self).__init__(*args, **kwargs)
if self.edited_entity is None:
self.edited_entity = self.cw_rset.complete_entity(self.cw_row or 0, self.cw_col or 0)
- self.form_add_hidden('__type', eidparam=True)
- self.form_add_hidden('eid')
+ self.add_hidden('__type', self.edited_entity.__regid__, eidparam=True)
+ self.add_hidden('eid', self.edited_entity.eid)
if kwargs.get('mainform', True): # mainform default to true in parent
- self.form_add_hidden(u'__maineid', self.edited_entity.eid)
+ self.add_hidden(u'__maineid', self.edited_entity.eid)
# If we need to directly attach the new object to another one
if self._cw.list_form_param('__linkto'):
for linkto in self._cw.list_form_param('__linkto'):
- self.form_add_hidden('__linkto', linkto)
+ self.add_hidden('__linkto', linkto)
if msg:
msg = '%s %s' % (msg, self._cw._('and linked'))
else:
msg = self._cw._('entity linked')
if msg:
- self.form_add_hidden('__message', msg)
+ self.add_hidden('__message', msg)
def session_key(self):
"""return the key that may be used to store / retreive data about a
@@ -240,6 +243,7 @@
return super(EntityFieldsForm, self)._field_has_error(field) \
and self.form_valerror.eid == self.edited_entity.eid
+ def default_renderer(self):
return self._cw.vreg['formrenderers'].select(
self.form_renderer_id, self._cw, rset=self.cw_rset, row=self.cw_row,
col=self.cw_col, entity=self.edited_entity)
--- a/web/views/management.py Mon Dec 21 20:18:53 2009 +0100
+++ b/web/views/management.py Mon Dec 21 20:21:56 2009 +0100
@@ -168,8 +168,8 @@
domid='reqperm%s' % entity.eid,
__redirectvid='security',
__redirectpath=entity.rest_path())
- form.form_add_hidden('require_permission', entity.eid, role='object',
- eidparam=True)
+ form.add_hidden('require_permission', entity.eid, role='object',
+ eidparam=True)
permnames = getattr(entity, '__permissions__', None)
cwpermschema = newperm.e_schema
if permnames is not None:
@@ -242,10 +242,10 @@
form = self._cw.vreg['forms'].select('base', self._cw, rset=None,
mainform=False)
binfo = text_error_description(ex, excinfo, req, eversion, cversions)
- form.form_add_hidden('description', binfo,
- # we must use a text area to keep line breaks
- widget=wdgs.TextArea({'class': 'hidden'}))
- form.form_add_hidden('__bugreporting', '1')
+ form.add_hidden('description', binfo,
+ # we must use a text area to keep line breaks
+ widget=wdgs.TextArea({'class': 'hidden'}))
+ form.add_hidden('__bugreporting', '1')
form.form_buttons = [wdgs.SubmitButton(MAIL_SUBMIT_MSGID)]
form.action = req.build_url('reportbug')
w(form.render())