That may seem "logical", but it doesn't seem to be true.

Unless otherwise specified, and the definition of db.Model does not
include any indication of "otherwise specified", pickling an instance
of a python class pickles all of its instance data.  If that instance
data includes instances, those instances are pickled also, and so on.
(Again, unless otherwise specified.)  In other words, pickle will
quite happily include vast amounts of data.

db.ReferenceProperty s maintain two pieces of information in the
corresponding db.Model instance, one for the key and the other for the
corresponding instance.  Both can be None.  The instance is filled in
on demand or when an instance is assigned to the corresponding
reference property.  If said instance has been filled in, it will be
included in the pickle.

The datastore operations are not like pickle.  .put({instance}) and
{instance}.put() store the key (if any) for db.ReferenceProperty s and
ignores the instance (if any).

> a = db.get(key_of_a)
# at this point a.b may have a key but will not have an instance - the
datastore
# doesn't contain instances for reference properties
# pickle.dumps(a) doesn't include an instance for a.b because a.b
doesn't have one.
> c = pickle.dumps(a)
> d = pickle.loads(c)
# immediately after the loads, d.b has a key but there's no instance
because there
# was no instance in the reference property of the pickled instance
# However, the following reference to d.b will cause an instance fetch
if the key is good
> e = d.b

# if the above instance fetch succeeded, the following will pickle the
both the instance
# and the key for d.b because the d.b reference caused a datastore
fetch and saved the result
# in d
f = pickle.dumps(d)

On Nov 11, 11:55 pm, gops <[EMAIL PROTECTED]> wrote:
> Ok , What seems logical is , it won't pickle the entity instance ,
> instead it just pickle the key , ( because , if there is a reference
> property in to that reference property , the chain reaction could make
> pickle whole the database.. :D ).
>
> On Nov 12, 12:43 pm, gops <[EMAIL PROTECTED]> wrote:
>
>
>
> > sorry typo in above post in code in last line ,
>
> > a = db.get(key_of_a)
> > c = pickle.dumps(a)
> > d = pickle.loads(c)
> > e = d.b # will gae fetch b behind the scene or it is already available
> > as an instance. ??- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to