« Return to Thread: Deep serialization of GAE models

Re: Deep serialization of GAE models

by Nick Joyce :: Rate this Message:

Reply to Author | View in Thread

On 2 Aug 2008, at 16:48, Fernando Correia wrote:

2008/8/2 Nick Joyce <nick@...>:
Both AMF0 and AMF3 can contain references to objects so if the participants
of a project were rendered individually, the project object would only be
rendered once and then references would be made to it (2 bytes usually).
Does that help?

When I first read your answer, I thought PyAMF already had support for
this feature of AMF. Now I understand that it doesn't, but it could be
added. Is that what you mean?

Sorry for not being clear, PyAMF already supports this feature.



I also realize now why the referenced class is being serialized. On
Google App Engine, when you use a reference property, it automatically
fetches the referenced object and returns it. So PyAMF's standard
serialization of GAE object will probably always perform a deep
serialization. I wonder if it will have problems with circular
references.

This is one of the features that the reference type is designed to support. An example:

import pyamf

x = [1, 2, 3]
x.append(x) 

y = pyamf.decode(pyamf.encode(x)).next()

assert id(y[3]) == id(y), 'not a circular reference'



Anyway, I was able to implement a pattern for returning DTOs. I
explain my approach in this article:

http://fernandoacorreia.wordpress.com/2008/08/02/returning-dtos-from-pyamf/

Thanks for your assistance.
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users


_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users

 « Return to Thread: Deep serialization of GAE models