[Cubicweb] Emptying a required attribute

Aurélien Campéas aurelien.campeas at logilab.fr
Thu Jul 9 19:40:08 CEST 2009


On Thu, Jul 09, 2009 at 07:07:22PM +0200, Florent Cayré wrote:
> Hi there,

Hi,

... there's an (encoding ?) problem with the diff ...

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



More information about the Cubicweb mailing list