Closed GoogleCodeExporter closed 9 years ago
Hi, Alex. Sorry to have missed this report. I need to make these things go to
the
mailing list.
Hm, that's an interesting one. I think slicehost might be using an older
version of
rails because Ruby's ActiveResource 2 doesn't like that xml either:
>> s.attributes
=> {"name"=>"cloudkick0", "status"=>"active", "addresses"=>["173.45.XXX.XXX",
"172.21.XXX.XXX"], "id"=>0, "progress"=>100, "bw_out"=>0.69, "bw_in"=>0.62,
"image_id"=>11, "ip_address"=>"173.45.XXX.XXX", "flavor_id"=>4}
>> s.to_xml
RuntimeError: Not all elements respond to to_xml
A solution I have used to handle older servers is to subclass the Connection
class
with one that does horrible regex hacks on the xml before/after
encoding/decoding.
Original comment by mark.r.r...@gmail.com
on 4 Apr 2009 at 3:57
I'm running into this exact same problem, was there any proper fix yet or
should I just use the workaround
above?
/Oli
Original comment by osvalds...@gmail.com
on 17 Nov 2009 at 10:15
The workaround above isn't exactly "correct" as it adds a "value" element to the
array, which is not the behavior of Ruby ARes, which preserves the array format.
>> class Slice < ActiveResource::Base
>> self.site = 'http://localhost:3000'
>> end
>> xml = '''...'''
>> site = Site.new(Hash.from_xml(xml)['site'])
>> site.addresses
=> ["173.45.XXX.XXX", "172.21.XXX.XXX"]
However as Mark mentions, to_xml blows up on the address Array
>> site.to_xml
RuntimeError: Not all elements respond to to_xml
...
So this is a problem with the server's XML not being ARes-compliant. PyARes is
a port
of the Ruby implementation, so this should be reported upstream if you feel
this is
really a bug.
Original comment by nick...@gmail.com
on 17 Nov 2009 at 4:45
Of course that should be "Slice.new(Hash.from_xml(xml)['slice'])" above
Original comment by nick...@gmail.com
on 17 Nov 2009 at 4:49
Original issue reported on code.google.com by
alexpo...@gmail.com
on 24 Feb 2009 at 7:34