[yast-devel] [webYaST] :dasherize => false not enough to stop dasherizing? (bug 551284)
Hi! Bug 551284 describes a problem of mail_settings plugin when it is called for a second time (while first time it was during basesystem sequence). The problem itself is that underscores are changed to dashes in the POST call. And indeed, mail_settings_controller of the webservice lacks the option to set dasherize to false in respond_to function, so the solution looked easy. However, I added that option, restarted both service and server, tried again and seen the same problem again. Any idea what else might be wrong? Other strange part of the problem is that when I remove registration step from the initial sequence, mail settings error does not occur. Jiri -- Jiri Suchomel SUSE LINUX, s.r.o. e-mail: jsuchome@suse.cz Lihovarská 1060/12 tel: +420 284 028 960 190 00 Praha 9, Czech Republic http://www.suse.cz -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
* Jiří Suchomel
Hi! Bug 551284 describes a problem of mail_settings plugin when it is called for a second time (while first time it was during basesystem sequence). The problem itself is that underscores are changed to dashes in the POST call. And indeed, mail_settings_controller of the webservice lacks the option to set dasherize to false in respond_to function, so the solution looked easy.
According to http://lists.rubyonrails.org/pipermail/rails/2006-July/057422.html this conversion seems to be done on purpose. Anyways, wrong list, opensuse-ruby might know more about this. Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
* Jiří Suchomel
Hi! Bug 551284 describes a problem of mail_settings plugin when it is called for a second time (while first time it was during basesystem sequence). The problem itself is that underscores are changed to dashes in the POST call. And indeed, mail_settings_controller of the webservice lacks the option to set dasherize to false in respond_to function, so the solution looked easy.
Hmm, http://www.bluequartz.us/phpBB2/viewtopic.php?p=318726&sid=ef2add12b91437160380ae3a8f078521 points to Hash.dasherize_xml which is set to 'true' by default. Try setting it to 'false'. Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Klaus Kaempf schrieb:
* Jiří Suchomel
[Nov 02. 2009 09:17]: Hi! Bug 551284 describes a problem of mail_settings plugin when it is called for a second time (while first time it was during basesystem sequence). The problem itself is that underscores are changed to dashes in the POST call. And indeed, mail_settings_controller of the webservice lacks the option to set dasherize to false in respond_to function, so the solution looked easy.
Hmm, http://www.bluequartz.us/phpBB2/viewtopic.php?p=318726&sid=ef2add12b91437160380ae3a8f078521 points to Hash.dasherize_xml which is set to 'true' by default.
Try setting it to 'false'.
Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
I am also interested in "Hash.dasherize_xml" If it does work I would be able to drop this work around from the registration model: # Hash.from_xml converts dashes in keys to underscores # by this we can not find out the correct key name (whether it was a dash or an underscore) # unfortunately the regcode keys in registration make excessive use of dashes AND underscores # that way the information gets lost what key to assign the correct value. # So the function "unrename_keys" will be overwritten module RailsHashFromWithoutConversationKey Hash.class_eval do def self.unrename_keys(params) case params.class.to_s when "Hash" params.inject({}) do |h,(k,v)| h[k.to_s] = unrename_keys(v) h end when "Array" params.map { |v| unrename_keys(v) } else params end end end end So please try this and tell us the result :-) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
On Monday 02 of November 2009 13:23:26 Stefan Schubert wrote:
Klaus Kaempf schrieb:
* Jiří Suchomel
[Nov 02. 2009 09:17]: Hi! Bug 551284 describes a problem of mail_settings plugin when it is called for a second time (while first time it was during basesystem sequence). The problem itself is that underscores are changed to dashes in the POST call. And indeed, mail_settings_controller of the webservice lacks the option to set dasherize to false in respond_to function, so the solution looked easy.
Hmm, http://www.bluequartz.us/phpBB2/viewtopic.php?p=318726&sid=ef2add12b91437 160380ae3a8f078521 points to Hash.dasherize_xml which is set to 'true' by default.
Try setting it to 'false'.
Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
I am also interested in "Hash.dasherize_xml" If it does work I would be able to drop this work around from the registration model:
# Hash.from_xml converts dashes in keys to underscores # by this we can not find out the correct key name (whether it was a dash or an underscore) # unfortunately the regcode keys in registration make excessive use of dashes AND underscores # that way the information gets lost what key to assign the correct value. # So the function "unrename_keys" will be overwritten module RailsHashFromWithoutConversationKey Hash.class_eval do def self.unrename_keys(params) case params.class.to_s when "Hash" params.inject({}) do |h,(k,v)| h[k.to_s] = unrename_keys(v) h end when "Array" params.map { |v| unrename_keys(v) } else params end end end end
What does this function actually do? You have the problem because of converting dashesh to underscores, but my problem is that underscores are changed to dashes. As I mentioned earlier, the problem in mail_settings does not appear if I remove registration step. Maybe just because of this code in registration is the mail_settings broken. Jiri -- Jiri Suchomel SUSE LINUX, s.r.o. e-mail: jsuchome@suse.cz Lihovarská 1060/12 tel: +420 284 028 960 190 00 Praha 9, Czech Republic http://www.suse.cz -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Jiří Suchomel write:
On Monday 02 of November 2009 13:23:26 Stefan Schubert wrote:
Klaus Kaempf schrieb:
* Jiří Suchomel
[Nov 02. 2009 09:17]: Hi! Bug 551284 describes a problem of mail_settings plugin when it is called for a second time (while first time it was during basesystem sequence). The problem itself is that underscores are changed to dashes in the POST call. And indeed, mail_settings_controller of the webservice lacks the option to set dasherize to false in respond_to function, so the solution looked easy.
Hmm, http://www.bluequartz.us/phpBB2/viewtopic.php?p=318726&sid=ef2add12b914 37 160380ae3a8f078521 points to Hash.dasherize_xml which is set to 'true' by default.
Try setting it to 'false'.
Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
I am also interested in "Hash.dasherize_xml" If it does work I would be able to drop this work around from the registration model:
# Hash.from_xml converts dashes in keys to underscores # by this we can not find out the correct key name (whether it was a dash or an underscore) # unfortunately the regcode keys in registration make excessive use of dashes AND underscores # that way the information gets lost what key to assign the correct value. # So the function "unrename_keys" will be overwritten module RailsHashFromWithoutConversationKey Hash.class_eval do def self.unrename_keys(params) case params.class.to_s when "Hash" params.inject({}) do |h,(k,v)| h[k.to_s] = unrename_keys(v) h end when "Array" params.map { |v| unrename_keys(v) } else params end end end end
What does this function actually do? You have the problem because of converting dashesh to underscores, but my problem is that underscores are changed to dashes.
As I mentioned earlier, the problem in mail_settings does not appear if I remove registration step. Maybe just because of this code in registration is the mail_settings broken.
Jiri
I think you find root of problems. Because correct way is not to overwrite behavior in class, but overwrite it in own instance. So if registration need this hack, it should do: xml = Hash.new(...) def xml.unrename_keys(params) ...#your hack end of course you can write it much pretty e.g. pass xml instance and overwrite method in separate code. -- Josef Reidinger YaST team maintainer of perl-Bootloader, YaST2-Repair, webyast modules language and time -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Josef Reidinger schrieb:
Jiří Suchomel write:
On Monday 02 of November 2009 13:23:26 Stefan Schubert wrote:
Klaus Kaempf schrieb:
* Jiří Suchomel
[Nov 02. 2009 09:17]: Hi! Bug 551284 describes a problem of mail_settings plugin when it is called for a second time (while first time it was during basesystem sequence). The problem itself is that underscores are changed to dashes in the POST call. And indeed, mail_settings_controller of the webservice lacks the option to set dasherize to false in respond_to function, so the solution looked easy.
Hmm, http://www.bluequartz.us/phpBB2/viewtopic.php?p=318726&sid=ef2add12b914 37 160380ae3a8f078521 points to Hash.dasherize_xml which is set to 'true' by default.
Try setting it to 'false'.
Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
I am also interested in "Hash.dasherize_xml" If it does work I would be able to drop this work around from the registration model:
# Hash.from_xml converts dashes in keys to underscores # by this we can not find out the correct key name (whether it was a dash or an underscore) # unfortunately the regcode keys in registration make excessive use of dashes AND underscores # that way the information gets lost what key to assign the correct value. # So the function "unrename_keys" will be overwritten module RailsHashFromWithoutConversationKey Hash.class_eval do def self.unrename_keys(params) case params.class.to_s when "Hash" params.inject({}) do |h,(k,v)| h[k.to_s] = unrename_keys(v) h end when "Array" params.map { |v| unrename_keys(v) } else params end end end end
What does this function actually do? You have the problem because of converting dashesh to underscores, but my problem is that underscores are changed to dashes.
As I mentioned earlier, the problem in mail_settings does not appear if I remove registration step. Maybe just because of this code in registration is the mail_settings broken.
Jiri
I think you find root of problems. Because correct way is not to overwrite behavior in class, but overwrite it in own instance. So if registration need this hack, it should do: xml = Hash.new(...) def xml.unrename_keys(params) ...#your hack end
of course you can write it much pretty e.g. pass xml instance and overwrite method in separate code.
The problem is that I am using the public Instance method "Hash.from_xml". So "xml.from_xml" does not work. Additional: "unrename_keys" is a private class. I must admit, that I am currently have no idea how to solve this. But I am searching.... :-) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Stefan Schubert write:
Josef Reidinger schrieb:
Jiří Suchomel write:
On Monday 02 of November 2009 13:23:26 Stefan Schubert wrote:
Klaus Kaempf schrieb:
* Jiří Suchomel
[Nov 02. 2009 09:17]: Hi! Bug 551284 describes a problem of mail_settings plugin when it is called for a second time (while first time it was during basesystem sequence). The problem itself is that underscores are changed to dashes in the POST call. And indeed, mail_settings_controller of the webservice lacks the option to set dasherize to false in respond_to function, so the solution looked easy.
Hmm, http://www.bluequartz.us/phpBB2/viewtopic.php?p=318726&sid=ef2add12b91 4 37 160380ae3a8f078521 points to Hash.dasherize_xml which is set to 'true' by default.
Try setting it to 'false'.
Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
I am also interested in "Hash.dasherize_xml" If it does work I would be able to drop this work around from the registration model:
# Hash.from_xml converts dashes in keys to underscores # by this we can not find out the correct key name (whether it was a dash or an underscore) # unfortunately the regcode keys in registration make excessive use of dashes AND underscores # that way the information gets lost what key to assign the correct value. # So the function "unrename_keys" will be overwritten module RailsHashFromWithoutConversationKey Hash.class_eval do def self.unrename_keys(params) case params.class.to_s when "Hash" params.inject({}) do |h,(k,v)| h[k.to_s] = unrename_keys(v) h end when "Array" params.map { |v| unrename_keys(v) } else params end end end end
What does this function actually do? You have the problem because of converting dashesh to underscores, but my problem is that underscores are changed to dashes.
As I mentioned earlier, the problem in mail_settings does not appear if I remove registration step. Maybe just because of this code in registration is the mail_settings broken.
Jiri
I think you find root of problems. Because correct way is not to overwrite behavior in class, but overwrite it in own instance. So if registration need this hack, it should do: xml = Hash.new(...) def xml.unrename_keys(params) ...#your hack end
of course you can write it much pretty e.g. pass xml instance and overwrite method in separate code.
The problem is that I am using the public Instance method "Hash.from_xml". So "xml.from_xml" does not work.
Additional: "unrename_keys" is a private class.
I must admit, that I am currently have no idea how to solve this. But I am searching.... :-)
Oh, OK, then solution is more tricky. Use alias to store old behavior and after you load xml restore old behavior. http://whynotwiki.com/Ruby_/_Method_aliasing_and_chaining#Can_you_alias_clas... -- Josef Reidinger YaST team maintainer of perl-Bootloader, YaST2-Repair, webyast modules language and time -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Josef Reidinger schrieb:
Stefan Schubert write:
Josef Reidinger schrieb:
Jiří Suchomel write:
On Monday 02 of November 2009 13:23:26 Stefan Schubert wrote:
Klaus Kaempf schrieb:
* Jiří Suchomel
[Nov 02. 2009 09:17]: > Hi! > Bug 551284 describes a problem of mail_settings plugin when it is > called for a second time (while first time it was during basesystem > sequence). The problem itself is that underscores are changed to > dashes in the POST call. And indeed, mail_settings_controller of the > webservice lacks the option to set dasherize to false in respond_to > function, so the solution looked easy. > Hmm, http://www.bluequartz.us/phpBB2/viewtopic.php?p=318726&sid=ef2add12b91 4 37 160380ae3a8f078521 points to Hash.dasherize_xml which is set to 'true' by default.
Try setting it to 'false'.
Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
I am also interested in "Hash.dasherize_xml" If it does work I would be able to drop this work around from the registration model:
# Hash.from_xml converts dashes in keys to underscores # by this we can not find out the correct key name (whether it was a dash or an underscore) # unfortunately the regcode keys in registration make excessive use of dashes AND underscores # that way the information gets lost what key to assign the correct value. # So the function "unrename_keys" will be overwritten module RailsHashFromWithoutConversationKey Hash.class_eval do def self.unrename_keys(params) case params.class.to_s when "Hash" params.inject({}) do |h,(k,v)| h[k.to_s] = unrename_keys(v) h end when "Array" params.map { |v| unrename_keys(v) } else params end end end end
What does this function actually do? You have the problem because of converting dashesh to underscores, but my problem is that underscores are changed to dashes.
As I mentioned earlier, the problem in mail_settings does not appear if I remove registration step. Maybe just because of this code in registration is the mail_settings broken.
Jiri
I think you find root of problems. Because correct way is not to overwrite behavior in class, but overwrite it in own instance. So if registration need this hack, it should do: xml = Hash.new(...) def xml.unrename_keys(params) ...#your hack end
of course you can write it much pretty e.g. pass xml instance and overwrite method in separate code.
The problem is that I am using the public Instance method "Hash.from_xml". So "xml.from_xml" does not work.
Additional: "unrename_keys" is a private class.
I must admit, that I am currently have no idea how to solve this. But I am searching.... :-)
Oh, OK, then solution is more tricky. Use alias to store old behavior and after you load xml restore old behavior. http://whynotwiki.com/Ruby_/_Method_aliasing_and_chaining#Can_you_alias_clas...
Sometimes solutions are quite simple :-) : class HashWithoutConversationKey < Hash; end HashWithoutConversationKey.class_eval do def self.unrename_keys(params) ..... end end ... @arguments = HashWithoutConversationKey.from_xml() BTW: There is an nice article concerning _Ruby: instance_eval and class_eval method definitions http://blog.jayfields.com/2007/03/ruby-instanceeval-and-classeval-method.htm... _http://blog.jayfields.com/2007/03/ruby-instanceeval-and-classeval-method.htm... Greetings Stefan -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Stefan Schubert write:
Josef Reidinger schrieb:
Stefan Schubert write:
Josef Reidinger schrieb:
Jiří Suchomel write:
On Monday 02 of November 2009 13:23:26 Stefan Schubert wrote:
Klaus Kaempf schrieb: > * Jiří Suchomel
[Nov 02. 2009 09:17]: >> Hi! >> Bug 551284 describes a problem of mail_settings plugin when it is >> called for a second time (while first time it was during basesystem >> sequence). The problem itself is that underscores are changed to >> dashes in the POST call. And indeed, mail_settings_controller of >> the webservice lacks the option to set dasherize to false in >> respond_to function, so the solution looked easy. > > Hmm, > http://www.bluequartz.us/phpBB2/viewtopic.php?p=318726&sid=ef2add12b >91 4 37 160380ae3a8f078521 points to Hash.dasherize_xml which is set > to 'true' by default. > > Try setting it to 'false'. > > Klaus > --- > SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) I am also interested in "Hash.dasherize_xml" If it does work I would be able to drop this work around from the registration model:
# Hash.from_xml converts dashes in keys to underscores # by this we can not find out the correct key name (whether it was a dash or an underscore) # unfortunately the regcode keys in registration make excessive use of dashes AND underscores # that way the information gets lost what key to assign the correct value. # So the function "unrename_keys" will be overwritten module RailsHashFromWithoutConversationKey Hash.class_eval do def self.unrename_keys(params) case params.class.to_s when "Hash" params.inject({}) do |h,(k,v)| h[k.to_s] = unrename_keys(v) h end when "Array" params.map { |v| unrename_keys(v) } else params end end end end
What does this function actually do? You have the problem because of converting dashesh to underscores, but my problem is that underscores are changed to dashes.
As I mentioned earlier, the problem in mail_settings does not appear if I remove registration step. Maybe just because of this code in registration is the mail_settings broken.
Jiri
I think you find root of problems. Because correct way is not to overwrite behavior in class, but overwrite it in own instance. So if registration need this hack, it should do: xml = Hash.new(...) def xml.unrename_keys(params) ...#your hack end
of course you can write it much pretty e.g. pass xml instance and overwrite method in separate code.
The problem is that I am using the public Instance method "Hash.from_xml". So "xml.from_xml" does not work.
Additional: "unrename_keys" is a private class.
I must admit, that I am currently have no idea how to solve this. But I am searching.... :-)
Oh, OK, then solution is more tricky. Use alias to store old behavior and after you load xml restore old behavior. http://whynotwiki.com/Ruby_/_Method_aliasing_and_chaining#Can_you_alias_c lass_methods.3F
Sometimes solutions are quite simple :-) :
class HashWithoutConversationKey < Hash; end HashWithoutConversationKey.class_eval do def self.unrename_keys(params) ..... end end
... @arguments = HashWithoutConversationKey.from_xml()
BTW: There is an nice article concerning _Ruby: instance_eval and class_eval method definitions <http://blog.jayfields.com/2007/03/ruby-instanceeval-and-classeval-method.h tml> _http://blog.jayfields.com/2007/03/ruby-instanceeval-and-classeval-method. html
Greetings Stefan
Nice, good solution. -- Josef Reidinger YaST team maintainer of perl-Bootloader, YaST2-Repair, webyast modules language and time -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
participants (4)
-
Jiří Suchomel
-
Josef Reidinger
-
Klaus Kaempf
-
Stefan Schubert