From 20339a5dad5e6ffa1ef408b41915b4a88525ad99 Mon Sep 17 00:00:00 2001 From: JJ Geewax Date: Fri, 3 Oct 2014 09:30:47 -0400 Subject: [PATCH 1/4] Fix #215: Helper for int and double now work as expected. --- gcloud/datastore/helpers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcloud/datastore/helpers.py b/gcloud/datastore/helpers.py index 5f3965213729..8ab6d571d6c6 100644 --- a/gcloud/datastore/helpers.py +++ b/gcloud/datastore/helpers.py @@ -7,7 +7,7 @@ from gcloud.datastore.key import Key -INT64 = Int64ValueChecker().CheckValue +check_int64_value = Int64ValueChecker().CheckValue def get_protobuf_attribute_and_value(val): @@ -56,7 +56,8 @@ def get_protobuf_attribute_and_value(val): elif isinstance(val, float): name, value = 'double', val elif isinstance(val, (int, long)): - name, value = 'integer', INT64(val) + check_int64_value(val) # This will raise an exception if invalid. + name, value = 'integer', val elif isinstance(val, basestring): name, value = 'string', val From 14613bbbafae012ecd3be45ce03fa978090a9a48 Mon Sep 17 00:00:00 2001 From: JJ Geewax Date: Sun, 5 Oct 2014 09:22:09 -0400 Subject: [PATCH 2/4] Pinned protobuf at >= 2.5.0. See discussion on Issue #215 for details. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8543b46d0e54..2391d98758a8 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ REQUIREMENTS = [ 'httplib2', 'oauth2client', - 'protobuf', + 'protobuf >= 2.5.0', 'pycrypto', 'pyopenssl', 'pytz', From 734bf27c611dfbd0b9ba23789b231a2cd9103229 Mon Sep 17 00:00:00 2001 From: JJ Geewax Date: Mon, 6 Oct 2014 08:49:46 -0400 Subject: [PATCH 3/4] Updated naming of global variable to follow PEP8. --- gcloud/datastore/helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcloud/datastore/helpers.py b/gcloud/datastore/helpers.py index 8ab6d571d6c6..ebecea125a19 100644 --- a/gcloud/datastore/helpers.py +++ b/gcloud/datastore/helpers.py @@ -7,7 +7,7 @@ from gcloud.datastore.key import Key -check_int64_value = Int64ValueChecker().CheckValue +INT_VALUE_CHECKER = Int64ValueChecker() def get_protobuf_attribute_and_value(val): @@ -56,7 +56,7 @@ def get_protobuf_attribute_and_value(val): elif isinstance(val, float): name, value = 'double', val elif isinstance(val, (int, long)): - check_int64_value(val) # This will raise an exception if invalid. + INT_VALUE_CHECKER.CheckValue(val) # This will raise an exception if invalid. name, value = 'integer', val elif isinstance(val, basestring): name, value = 'string', val From e8123f4c034f8172e6f353145dc3e879c51fc563 Mon Sep 17 00:00:00 2001 From: JJ Geewax Date: Tue, 7 Oct 2014 09:58:08 -0400 Subject: [PATCH 4/4] Always cast int and long values to a long when preparing for a request. --- gcloud/datastore/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcloud/datastore/helpers.py b/gcloud/datastore/helpers.py index ebecea125a19..ed1caf2071f9 100644 --- a/gcloud/datastore/helpers.py +++ b/gcloud/datastore/helpers.py @@ -57,7 +57,7 @@ def get_protobuf_attribute_and_value(val): name, value = 'double', val elif isinstance(val, (int, long)): INT_VALUE_CHECKER.CheckValue(val) # This will raise an exception if invalid. - name, value = 'integer', val + name, value = 'integer', long(val) # Always cast to a long. elif isinstance(val, basestring): name, value = 'string', val