Mailinglist Archive: yast-devel (163 mails)

< Previous Next >
[yast-devel] WebYaST: how to pass empty string to rest-service?
  • From: Jiří Suchomel <jsuchome@xxxxxxx>
  • Date: Wed, 16 Sep 2009 09:47:46 +0200
  • Message-id: <200909160947.47066.jsuchome@xxxxxxx>
in administrator module I have a POST request from client that contains the
information about root password and mail aliases. Sometimes I would like to
pass an empty value (for mail aliases, to reset it to no alias) and to
distinguish the empty value from nil (nil has a meaning do not try to save
this, while empty means save empty).

So, for example I have this object in webclient controller:
@administrator.password = nil
@administrator.aliases = ""

and I'm calling POST with

However, on the server part, I get this as parameters:

{"format"=>"xml", "action"=>"create", "administrator"=>{"aliases"=>nil,
"password"=>nil}, "controller"=>"administrator"}

So both values are set to nil.
When debugging, we saw that the RAW_POST_DATA has a value

"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<administrator>\n
<aliases></aliases>\n <password

which is converted by from_xml this way even if aliases tag looks differently
from password tag:

Hash.from_xml("<?xml?>\n<administrator>\n <aliases></aliases>\n <password
{"administrator"=>{"aliases"=>nil, "password"=>nil}}

It would work if the request would contain

<aliases type='string'></aliases> instead of <aliases></aliases>,

however I don't know how to achieve this; using

xml.aliases aliases, {:type => "string"}

in models/administrator.rb's to_xml doesn't seem to help.


Jiri Suchomel

SUSE LINUX, s.r.o. e-mail: jsuchome@xxxxxxx
Lihovarská 1060/12 tel: +420 284 028 960
190 00 Praha 9, Czech Republic
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups