nickesk / pyactiveresource

Automatically exported from code.google.com/p/pyactiveresource
Other
0 stars 0 forks source link

bad xml with list elements #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. With a dict like :

appointment = {
     'fiche': { 'id': fiche_id },
     'date': '2012-02-06 12:45:00',
     'intervention_ids': [ 1000, 2000 ]
  }

2. the XML is :

<appointment>
  <date>2012-02-06 12:45:00</date>
  <fiche>
    <id type="integer">5334237</id>
  </fiche>
  <intervention-ids type="array">
    <intervention-id />
    <intervention-id />
  </intervention-ids>
</appointment>

What is the expected output? What do you see instead?

All "intervention-id" are empty. I expect something like :

  <intervention-ids type="array">
    <intervention-id type="integer">1000</intervention-id>
    <intervention-id type="integer">2000</intervention-id>
  </intervention-ids>

What version of the product are you using? On what operating system?

I use trunk, r92

Original issue reported on code.google.com by tom.noel on 4 Feb 2012 at 12:37

GoogleCodeExporter commented 9 years ago
That doesn't seem to be the way active support works in ruby. Given that we aim 
for compatibility, I think it should stay as is.

{'fiche' => {'id' => 5345346}, 'date' => '2012-etc', 'intervention_ids' => 
[1000, 2000]}.to_xml
RuntimeError: Not all elements respond to to_xml
    from /var/lib/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/array/conversions.rb:163:in `to_xml'
    from /var/lib/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/hash/conversions.rb:106
    from /var/lib/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/hash/conversions.rb:101:in `each'
    from /var/lib/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/hash/conversions.rb:101
    from /var/lib/gems/1.8/gems/activesupport-2.3.2/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb:134:in `call'
    from /var/lib/gems/1.8/gems/activesupport-2.3.2/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb:134:in `_nested_structures'
    from /var/lib/gems/1.8/gems/activesupport-2.3.2/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb:58:in `method_missing'
    from /var/lib/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/hash/conversions.rb:100:in `__send__'
    from /var/lib/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/hash/conversions.rb:100:in `to_xml'
    from (irb):2

A workaround for this issue would be to register a SERIALIZER method in 
pyactiveresource.util

Original comment by mark.r.r...@gmail.com on 19 Apr 2012 at 3:09