# HG changeset patch # User Adrien Di Mascio # Date 1249455940 -7200 # Node ID f76a38731bc1b87103964d3f299635ba770a4704 # Parent 3e91d1857bc5fa0afc0e6fa0f663928badae65c6 [forms] work-in-progress: get rid of edits- / edito- diff -r 3e91d1857bc5 -r f76a38731bc1 web/formfields.py --- a/web/formfields.py Wed Aug 05 08:40:20 2009 +0200 +++ b/web/formfields.py Wed Aug 05 09:05:40 2009 +0200 @@ -425,17 +425,6 @@ widget = TextInput -class HiddenInitialValueField(Field): - def __init__(self, visible_field): - name = 'edit%s-%s' % (visible_field.role[0], visible_field.name) - super(HiddenInitialValueField, self).__init__( - name=name, widget=HiddenInput, eidparam=True) - self.visible_field = visible_field - - def format_single_value(self, req, value): - return self.visible_field.format_single_value(req, value) - - class RelationField(Field): def __init__(self, **kwargs): kwargs.setdefault('sort', False) diff -r 3e91d1857bc5 -r f76a38731bc1 web/views/editcontroller.py --- a/web/views/editcontroller.py Wed Aug 05 08:40:20 2009 +0200 +++ b/web/views/editcontroller.py Wed Aug 05 09:05:40 2009 +0200 @@ -68,8 +68,8 @@ self.handle_relation(rschema, formparams, x, entity, True) # XXX this processes *all* pending operations of *all* entities - if form.has_key('__delete'): - todelete += req.list_form_param('__delete', form, pop=True) + if req.form.has_key('__delete'): + todelete += req.list_form_param('__delete', req.form, pop=True) if todelete: self.delete_relations(parse_relations_descr(todelete)) if form.has_key('__insert'): diff -r 3e91d1857bc5 -r f76a38731bc1 web/views/editforms.py --- a/web/views/editforms.py Wed Aug 05 08:40:20 2009 +0200 +++ b/web/views/editforms.py Wed Aug 05 09:05:40 2009 +0200 @@ -481,12 +481,6 @@ def add_hiddens(self, form, entity, peid, rtype, role): # to ease overriding (see cubes.vcsfile.views.forms for instance) - if self.keep_entity(form, entity, peid, rtype): - if entity.has_eid(): - rval = entity.eid - else: - rval = INTERNAL_FIELD_VALUE - form.form_add_hidden('edit%s-%s:%s' % (role[0], rtype, peid), rval) form.form_add_hidden(name='%s:%s' % (rtype, peid), value=entity.eid, id='rel-%s-%s-%s' % (peid, rtype, entity.eid)) diff -r 3e91d1857bc5 -r f76a38731bc1 web/views/formrenderers.py --- a/web/views/formrenderers.py Wed Aug 05 08:40:20 2009 +0200 +++ b/web/views/formrenderers.py Wed Aug 05 09:05:40 2009 +0200 @@ -18,7 +18,6 @@ from cubicweb.web import eid_param from cubicweb.web import formwidgets as fwdgs from cubicweb.web.widgets import checkbox -from cubicweb.web.formfields import HiddenInitialValueField class FormRenderer(AppObject): @@ -160,8 +159,6 @@ return tag + '>' def display_field(self, form, field): - if isinstance(field, HiddenInitialValueField): - field = field.visible_field return (self.display_fields is None or field.name in form.internal_fields or (field.name, field.role) in self.display_fields @@ -249,8 +246,6 @@ def display_field(self, form, field): if not super(EntityBaseFormRenderer, self).display_field(form, field): - if isinstance(field, HiddenInitialValueField): - field = field.visible_field ismeta = form.edited_entity.e_schema.is_metadata(field.name) return ismeta is not None and ( ismeta[0] in self.display_fields or diff -r 3e91d1857bc5 -r f76a38731bc1 web/views/forms.py --- a/web/views/forms.py Wed Aug 05 08:40:20 2009 +0200 +++ b/web/views/forms.py Wed Aug 05 09:05:40 2009 +0200 @@ -394,7 +394,7 @@ """return field's *typed* value overriden to deal with - * special eid / __type / edits- / edito- fields + * special eid / __type * lookup for values on edited entities """ attr = field.name @@ -403,14 +403,6 @@ return entity.eid if not field.eidparam: return super(EntityFieldsForm, self).form_field_value(field, load_bytes) - if attr.startswith('edits-') or attr.startswith('edito-'): - # edit[s|o]- fieds must have the actual value stored on the entity - assert hasattr(field, 'visible_field') - vfield = field.visible_field - assert vfield.eidparam - if entity.has_eid(): - return self.form_field_value(vfield) - return INTERNAL_FIELD_VALUE if attr == '__type': return entity.id if self.schema.rschema(attr).is_final():