Last active
August 29, 2015 14:12
-
-
Save dhermes/3dd5c0d1fd365d995a5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> # See https://github.com/GoogleCloudPlatform/gcloud-python/pull/404 | |
... | |
>>> from gcloud.datastore import datastore_v1_pb2 as datastore_pb | |
>>> | |
>>> mutation = datastore_pb.Mutation() | |
>>> insert_auto = mutation.insert_auto_id.add() | |
>>> path_elt = insert_auto.key.path_element.add() | |
>>> path_elt.kind = 'Foo' | |
>>> | |
>>> prop = insert_auto.property.add() | |
>>> prop.name = 'fooProp' | |
>>> | |
>>> # http://stackoverflow.com/q/10998254/1068170 | |
... | |
>>> prop_parent_weak = prop._listener._parent_message_weakref | |
>>> prop_grandparent_weak = prop_parent_weak._listener._parent_message_weakref | |
>>> prop_parent_actual = prop_grandparent_weak.insert_auto_id[0] | |
>>> print insert_auto is prop_parent_actual | |
True | |
>>> | |
>>> print mutation | |
insert_auto_id { | |
key { | |
path_element { | |
kind: "Foo" | |
} | |
} | |
property { | |
name: "fooProp" | |
} | |
} | |
>>> print len(prop_parent_actual.property) | |
1 | |
>>> print prop_parent_actual.property[0] is prop | |
True | |
>>> prop_parent_actual.property.remove(prop) | |
>>> print mutation | |
insert_auto_id { | |
key { | |
path_element { | |
kind: "Foo" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment