[Cubicweb] Emptying a required attribute

Sylvain Thénault sylvain.thenault at logilab.fr
Fri Jul 10 09:29:12 CEST 2009


On 09 juillet 19:07, Florent Cayré wrote:
> Hi there,
> 
> when I want to update a required attribute value to the empty string using a
> "edit_field" remote call, I get an error like :
> MY_ATTRIBUTE : required attribute
> 
> I could solve the problem by patching the edit controller's _needs_edition
> method, that transforms my empty value into a None value :
> 
> --- a/web/views/editcontroller.py       Tue Jul 07 13:57:26 2009 +0200
> +++ b/web/views/editcontroller.py       Thu Jul 09 00:06:09 2009 +0200
> @@ -170,7 +170,7 @@
>          editkey = 'edits-%s' % rtype
>          if not editkey in formparams:
>              return False, None # not edited
> -        value = formparams.get(rtype) or None
> +        value = formparams.get(rtype, None)
>          if entity.has_eid() and (formparams.get(editkey) or None) == value:
>              return False, None # not modified
>          if value == INTERNAL_FIELD_VALUE:
> 
> Not sure it is the right thing to do, perhaps someone can tell.

as I said on #cubicweb, currently the editcontroller strip strings and 
consider empty string as None. Changing this requires more work than this
patch...

-- 
Sylvain Thénault                               LOGILAB, Paris (France)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org




More information about the Cubicweb mailing list