[Cubicweb] Emptying a required attribute

Florent Cayré florent at secondweb.fr
Thu Jul 9 19:07:22 CEST 2009


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.

Thanks in advance,
Regards,
Florent.


-- 
Ce message est la propriété de SecondWeb et peut contenir des informations
confidentielles. Si vous n'êtes pas le destinataire désigné, nous vous
remercions de bien vouloir nous en aviser immédiatement et de nous retourner
ce message ou de le détruire, sans faire un quelconque usage de son contenu,
ni le communiquer ou le diffuser, ni en prendre copie, électronique ou non.

This message is the property of SecondWeb and may contain confidential
information. If you are not the designated recipient, please notify us
immediately and return the message to us or destroy it, without making any
use whatsoever of the contents thereof. Furthermore you should not forward
or copy the message by electronic or other means.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubicweb.org/pipermail/cubicweb/attachments/20090709/98177a33/attachment-0048.html>


More information about the Cubicweb mailing list