Ticket #355 (assigned enhancement)

Opened 2 months ago

Last modified 44 hours ago

Option to map ArrayCollection/ObjectProxy to (list, tuple)/dict

Reported by: dthompso Owned by: dthompso
Priority: major Milestone: 0.4
Component: AMF3 Version:
Keywords: Cc: dthompso@…

Description (last modified by thijs) (diff)

I am experimenting with pyamf and the SQLAlchemy adapter. Everything is working well, but my Flex app uses ObjectProxy and ArrayCollection extensively for binding. Using the current code base, if I want to use ArrayCollection and ObjectProxy with SQLAlchemy, I would have to manually convert to/from pyamf.flex.ObjectProxy and pyamf.flex.ArrayCollection after reading from the DB and before writing to the DB. I think many flex users would appreciate an optional parameter in the gateway to map all lists and tuples to ArrayCollection and all dicts to ObjectProxy.

I am currently using lame hacks in pyamf.pyamf3.readObject and pyamf.pyamf3.writeList and pyamf.pyamf3.writeDict to achieve the desired result.

Attachments

amf3.diff (4.1 KB) - added by dthompso 2 months ago.
hacks to amf3.py

Change History

comment:1 Changed 2 months ago by thijs

  • owner changed from nick to mvtellingen
  • status changed from new to assigned
  • component changed from AMF3 to Adapters
  • description modified (diff)
  • type changed from defect to enhancement

comment:2 Changed 2 months ago by thijs

  • description modified (diff)

comment:3 Changed 2 months ago by thijs

  • milestone changed from 0.4 to 0.5

Moving to 0.5, the planned milestone for the sqlalchemy adapter release.

comment:4 Changed 2 months ago by dthompso

  • cc dthompso@… added
  • priority changed from major to blocker

I was hoping for a more global level option to use ArrayCollection and ObjectProxy by default for all data, which would be very helpful for developing with Flex. I just mentioned SQLAlchemy because I happened to be working with that adapter, but really my original feature request has nothing to do with SQLAlchemy. I shouldn't have even mentioned it.

Anyway, I attached a diff of the hacks I've done locally to get it working the way I require, and I was hoping someone could take a look and decide if my changes could fit in. Tests fail if you set 'use_proxies' to True for obvious reasons, so new tests would be needed as well.

comment:5 Changed 2 months ago by dthompso

  • priority changed from blocker to major

Changed 2 months ago by dthompso

hacks to amf3.py

comment:6 Changed 2 days ago by esvist

  • milestone 0.5 deleted

I completely agree with dthompso that it has nothing to do especially with SQLAlchemy and a general option for default ObjectProxy/ArrayCollection? mapping would be highly appreciated by many Flex developers. Please consider support this for 0.4

comment:7 Changed 2 days ago by esvist

  • version 0.3.1 deleted
  • milestone set to 0.5

Sorry for changing the milestone by previous post.

comment:8 Changed 2 days ago by nick

  • owner changed from mvtellingen to dthompso
  • component changed from Adapters to AMF3
  • milestone changed from 0.5 to 0.4

We're going to require unit tests for this patch to be included. Also I would make the option an Encoder/Decoder instance property not a module level setting.

comment:9 Changed 44 hours ago by dthompso

After some more testing I've found that the patch works correctly for Array/ArrayCollection mapping, but does not work correctly for Dict/ObjectProxy mapping. If I have some spare time I will fix this and look at making some unit tests.

Note: See TracTickets for help on using tickets.