Ticket #342 (assigned defect)

Opened 3 months ago

Last modified 20 hours ago

Problem decoding objects that map to GAE db.Model objects with required properties

Reported by: ricardo Owned by:
Priority: minor Milestone: 0.4
Component: Decoder Version: 0.3.1
Keywords: review Cc:

Description

Decoding works fine unless properties in the Model object are set to required or have validator functions. At present the decoder instantiates an empty object and then assigns all properties from the incoming client object. Upon instantiation, Google App Engine raises "Bad Value Error" for all those properties that are required or that have validator functions not built to accept None as an acceptable value (which surely most validator functions should not).

Attachments

app.yaml (101 bytes) - added by ricardo 3 months ago.
client.py (0.7 KB) - added by ricardo 3 months ago.
server.py (0.8 KB) - added by ricardo 3 months ago.

Change History

comment:1 Changed 3 months ago by thijs

  • component changed from Remoting to Decoder
  • milestone changed from Flex Messaging to 0.4

Ricardo, can you maybe provide a simple test program that reproduces this issue? Makes it easier to figure out the issue.

comment:2 Changed 3 months ago by ricardo

I will work on a small program to this effect, but it may take a few days. In the meantime I should explain myself a little better. I meant that the problem arises when using a Flex RemoteObject to submit an ActionScript ValueObject? that has been defined using the [Bindable] and [RemoteClass?(alias="address.of.object.on.server")] tags to a Google App Engine server. The server tries to map the incoming ValueObject? to an object of the server class defined by the alias. For Model objects with properties that are required or have a validator function, the mapping fails when the server attempts to instantiate the class alias, since pyamf instantiates an empty object first and THEN tries to assign its properties. Specifically, in pyamf 0.3.1 the failure occurs at line 368 of pyamf.init.py, which tries to instantiate the aliased class.

The solution shouldn't be that hard. Google App Engine Model objects can be instantiated with a dictionary of property keywords and values. If pyamf were configured to accept a dictionary of properties as input when instantiating server-side objects, the problem would go away. Line 368 of init.py is already written to accept a kwargs argument. The problem is that line 1105 of pyamf.amf3 (obj = class_def.alias()) doesn't feed any parameter in to be picked up by line 368 of init.py.

Changed 3 months ago by ricardo

Changed 3 months ago by ricardo

Changed 3 months ago by ricardo

comment:3 Changed 3 months ago by ricardo

The attached three files, dropped into a Google App Engine testing environment, should do to illustrate the problem. Sorry, the problem has nothing to do with Flex per se, so the ticket should be retitled to something like "Problem decoding objects that map to Google App Engine db.Model objects with required properties".

comment:4 Changed 3 months ago by thijs

  • summary changed from problems decoding Flex RemoteObjects to Google App Engine Model objects to Problem decoding objects that map to GAE db.Model objects with required properties

Updated the title, thx for the sample files.

comment:5 Changed 43 hours ago by nick

  • status changed from new to accepted

This issue has now been inadvertently resolved in #307 which is currently up for review.

comment:6 Changed 20 hours ago by nick

  • keywords review added
  • owner nick deleted
  • status changed from accepted to assigned
Note: See TracTickets for help on using tickets.