def writeGAEObject(obj, encoder=None):
 if (not obj.is_saved()):
  encoder.writeObject(obj)
  return
 context = encoder.context
 kls = obj.__class__
 s = obj.key()
 gae_objects = getGAEObjects(context)
 try:
  referenced_object = gae_objects.getClassKey(kls, s)
 except KeyError:
  referenced_object = obj
  gae_objects.addClassKey(kls, s, obj)
 encoder.writeObject(referenced_object)

def writeGAEObject ( obj , encoder = None ) : if ( not obj . is_saved ( ) ) : encoder . writeObject ( obj ) return context = encoder . context kls = obj . __class__ s = obj . key ( ) gae_objects = getGAEObjects ( context ) try : referenced_object = gae_objects . getClassKey ( kls , s ) except KeyError : referenced_object = obj gae_objects . addClassKey ( kls , s , obj ) encoder . writeObject ( referenced_object )
the gae datastore creates new instances of objects for each get request .