Ticket #488 (closed defect: fixed)

Opened 12 months ago

Last modified 11 months ago

RemotingService raises TypeError when deserializing an ArrayCollection

Reported by: mrflay Owned by: nick
Priority: major Milestone: 0.4.2
Component: Utility Version: 0.4.1
Keywords: ArrayCollection RemotingService Cc:
Fixed in revision: 2286 Branch: arraycollection-source-488
Author: mrflay, nick

Description (last modified by thijs) (diff)

I have a pyamf 0.4.1 client that communicates with a BlazeDS 3.0.0.544 service running in a JBoss 4.2 application server.

The following error is raised on the client when an ArrayCollection is being deserialized.

Traceback (most recent call last):
  File "test.py", line 19, in <module>
    print service.list("3F3A66CA-B1BE-73D6-276D-D7CA9453BA90")
  File "build/bdist.linux-i686/egg/pyamf/remoting/client/__init__.py", line 52, in __call__
  File "build/bdist.linux-i686/egg/pyamf/remoting/client/__init__.py", line 101, in _call
  File "build/bdist.linux-i686/egg/pyamf/remoting/client/__init__.py", line 409, in execute_single
  File "build/bdist.linux-i686/egg/pyamf/remoting/client/__init__.py", line 479, in _getResponse
  File "build/bdist.linux-i686/egg/pyamf/remoting/__init__.py", line 615, in decode
  File "build/bdist.linux-i686/egg/pyamf/remoting/__init__.py", line 454, in _read_body
  File "build/bdist.linux-i686/egg/pyamf/__init__.py", line 677, in readElement
  File "build/bdist.linux-i686/egg/pyamf/amf0.py", line 318, in readTypedObject
  File "build/bdist.linux-i686/egg/pyamf/amf0.py", line 365, in _readObject
  File "build/bdist.linux-i686/egg/pyamf/__init__.py", line 554, in applyAttributes
  File "build/bdist.linux-i686/egg/pyamf/util/__init__.py", line 767, in set_attrs
TypeError: list indices must be integers

Cause:

The set_attrs method cannot initialize the ArrayCollection since it expects the associated attrs data to be an array, but it is actually an object {'source':[{'foo':'bar'},...]}.

Adding the following code

    if isinstance(obj, pyamf.flex.ArrayCollection):
        obj.extend(attrs['source'])
        return

to the beginning of the set_attrs method allows the ArrayCollection to be deserialized on the client.

Attachments

pyamf_arraycollection.patch Download (511 bytes) - added by mrflay 12 months ago.
patch

Change History

Changed 12 months ago by mrflay

patch

  Changed 12 months ago by thijs

  • description modified (diff)
  • author set to mrflay

  Changed 12 months ago by nick

  • status changed from new to accepted
  • branch set to pyamf/branches/arraycollection-source-488

PyAMF should support the  source property.

follow-up: ↓ 4   Changed 11 months ago by thijs

mrflay, could you take a stab at unit tests for this change as well? Nick already created a branch at pyamf/branches/arraycollection-source-488 that you can work against. As noted in the previous comment, we need to support an additional source property for ArrayCollection.

in reply to: ↑ 3   Changed 11 months ago by mrflay

Sure, I'll take a look at it.

  Changed 11 months ago by nick

  • keywords review added
  • owner changed from nick to mrflay
  • status changed from accepted to assigned

I have applied a change for this in r2276 (including tests). Can you check this against BlazeDS to ensure that this is now working?

Thanks!

  Changed 11 months ago by thijs

  • keywords review removed
  • owner changed from mrflay to nick
  • author changed from mrflay to mrflay, nick

The pyflakes step is failing:  http://buildbot.pyamf.org/builders/x86-macosx-py25/builds/100/steps/pyflakes

After that it's ready to merge.

  Changed 11 months ago by nick

  • status changed from assigned to closed
  • revfixed set to 2286
  • resolution set to fixed
  • branch changed from pyamf/branches/arraycollection-source-488 to arraycollection-source-488
Note: See TracTickets for help on using tickets.