Merge lp:~cjwatson/lazr.restful/py3-dict-methods into lp:lazr.restful

Proposed by Colin Watson
Status: Merged
Merged at revision: 248
Proposed branch: lp:~cjwatson/lazr.restful/py3-dict-methods
Merge into: lp:lazr.restful
Diff against target: 202 lines (+22/-22)
10 files modified
src/lazr/restful/_resource.py (+3/-3)
src/lazr/restful/declarations.py (+2/-2)
src/lazr/restful/docs/webservice-declarations.rst (+1/-1)
src/lazr/restful/docs/webservice-marshallers.rst (+1/-1)
src/lazr/restful/docs/webservice.rst (+2/-3)
src/lazr/restful/example/base/tests/representation-cache.txt (+6/-5)
src/lazr/restful/metazcml.py (+1/-1)
src/lazr/restful/simple.py (+1/-1)
src/lazr/restful/tales.py (+1/-1)
src/lazr/restful/tests/test_declarations.py (+4/-4)
To merge this branch: bzr merge lp:~cjwatson/lazr.restful/py3-dict-methods
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+387905@code.launchpad.net

Commit message

Handle dict method changes in Python 3.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/lazr/restful/_resource.py'
--- src/lazr/restful/_resource.py 2020-06-30 15:52:03 +0000
+++ src/lazr/restful/_resource.py 2020-07-22 23:32:54 +0000
@@ -1221,7 +1221,7 @@
1221 # The changeset contained new values for some of this object's1221 # The changeset contained new values for some of this object's
1222 # fields, and the notification event may have changed others.1222 # fields, and the notification event may have changed others.
1223 # Clear out any fields that changed.1223 # Clear out any fields that changed.
1224 for name, cached in self._unmarshalled_field_cache.items():1224 for name, cached in list(self._unmarshalled_field_cache.items()):
1225 cached, (field, old_value, flag) = cached1225 cached, (field, old_value, flag) = cached
1226 if flag is IUnmarshallingDoesntNeedValue:1226 if flag is IUnmarshallingDoesntNeedValue:
1227 continue1227 continue
@@ -1986,14 +1986,14 @@
1986 schema, self.request)1986 schema, self.request)
19871987
1988 singular = adapter.singular_type1988 singular = adapter.singular_type
1989 assert not singular_names.has_key(singular), (1989 assert singular not in singular_names, (
1990 "Both %s and %s expose the singular name '%s'."1990 "Both %s and %s expose the singular name '%s'."
1991 % (singular_names[singular].__name__,1991 % (singular_names[singular].__name__,
1992 schema.__name__, singular))1992 schema.__name__, singular))
1993 singular_names[singular] = schema1993 singular_names[singular] = schema
19941994
1995 plural = adapter.plural_type1995 plural = adapter.plural_type
1996 assert not plural_names.has_key(plural), (1996 assert plural not in plural_names, (
1997 "Both %s and %s expose the plural name '%s'."1997 "Both %s and %s expose the plural name '%s'."
1998 % (plural_names[plural].__name__,1998 % (plural_names[plural].__name__,
1999 schema.__name__, plural))1999 schema.__name__, plural))
20002000
=== modified file 'src/lazr/restful/declarations.py'
--- src/lazr/restful/declarations.py 2020-02-05 10:46:46 +0000
+++ src/lazr/restful/declarations.py 2020-07-22 23:32:54 +0000
@@ -405,7 +405,7 @@
405 # If any keywords are left over, raise an exception.405 # If any keywords are left over, raise an exception.
406 if len(kwparams) > 0:406 if len(kwparams) > 0:
407 raise TypeError("exported got an unexpected keyword "407 raise TypeError("exported got an unexpected keyword "
408 "argument '%s'" % kwparams.keys()[0])408 "argument '%s'" % list(kwparams)[0])
409409
410 # Now incorporate the list of named dicts into the VersionedDict.410 # Now incorporate the list of named dicts into the VersionedDict.
411 for version, annotations in reversed(versioned_annotations):411 for version, annotations in reversed(versioned_annotations):
@@ -1254,7 +1254,7 @@
1254 # Go through the fields and build up a picture of what this entry looks1254 # Go through the fields and build up a picture of what this entry looks
1255 # like for every version.1255 # like for every version.
1256 adapters_by_version = {}1256 adapters_by_version = {}
1257 fields = getFields(content_interface).items()1257 fields = list(getFields(content_interface).items())
1258 for version, iface in webservice_interfaces:1258 for version, iface in webservice_interfaces:
1259 fields.extend(getFields(iface).items())1259 fields.extend(getFields(iface).items())
1260 for name, field in fields:1260 for name, field in fields:
12611261
=== modified file 'src/lazr/restful/docs/webservice-declarations.rst'
--- src/lazr/restful/docs/webservice-declarations.rst 2020-06-30 13:33:53 +0000
+++ src/lazr/restful/docs/webservice-declarations.rst 2020-07-22 23:32:54 +0000
@@ -2352,7 +2352,7 @@
23522352
2353 >>> attrs['params']['arg']2353 >>> attrs['params']['arg']
2354 <zope.schema._field.Float object...>2354 <zope.schema._field.Float object...>
2355 >>> attrs['params'].keys()2355 >>> list(attrs['params'])
2356 ['arg']2356 ['arg']
23572357
2358 >>> attrs['return_type']2358 >>> attrs['return_type']
23592359
=== modified file 'src/lazr/restful/docs/webservice-marshallers.rst'
--- src/lazr/restful/docs/webservice-marshallers.rst 2020-06-30 15:52:03 +0000
+++ src/lazr/restful/docs/webservice-marshallers.rst 2020-07-22 23:32:54 +0000
@@ -928,7 +928,7 @@
928 ['Dessert', 'Vegetarian']928 ['Dessert', 'Vegetarian']
929929
930 >>> unmarshalled = dict_marshaller.unmarshall(None, marshalled_dict)930 >>> unmarshalled = dict_marshaller.unmarshall(None, marshalled_dict)
931 >>> sorted(unmarshalled.iteritems())931 >>> sorted(unmarshalled.items())
932 [(u'bar', 'General'), (u'foo', 'Vegetarian')]932 [(u'bar', 'General'), (u'foo', 'Vegetarian')]
933933
934The unmarshall() method will return None when given None.934The unmarshall() method will return None when given None.
935935
=== modified file 'src/lazr/restful/docs/webservice.rst'
--- src/lazr/restful/docs/webservice.rst 2020-02-04 13:17:32 +0000
+++ src/lazr/restful/docs/webservice.rst 2020-07-22 23:32:54 +0000
@@ -652,10 +652,9 @@
652 >>> from lazr.restful import Entry652 >>> from lazr.restful import Entry
653 >>> from lazr.restful.testing.webservice import FakeRequest653 >>> from lazr.restful.testing.webservice import FakeRequest
654654
655 >>> from UserDict import UserDict655 >>> class FakeDict(dict):
656 >>> class FakeDict(UserDict):
657 ... def __init__(self, interface):656 ... def __init__(self, interface):
658 ... UserDict.__init__(self)657 ... super(FakeDict, self).__init__()
659 ... self.interface = interface658 ... self.interface = interface
660 ... def __getitem__(self, key):659 ... def __getitem__(self, key):
661 ... return self.interface660 ... return self.interface
662661
=== modified file 'src/lazr/restful/example/base/tests/representation-cache.txt'
--- src/lazr/restful/example/base/tests/representation-cache.txt 2020-02-04 13:17:32 +0000
+++ src/lazr/restful/example/base/tests/representation-cache.txt 2020-07-22 23:32:54 +0000
@@ -94,8 +94,9 @@
9494
95 >>> test_cache.set("Cache this.", json, "1.0", "representation")95 >>> test_cache.set("Cache this.", json, "1.0", "representation")
96 >>> test_cache.set("Don't cache this.", json, "1.0", "representation")96 >>> test_cache.set("Don't cache this.", json, "1.0", "representation")
97 >>> test_dict.keys()97 >>> for key in test_dict:
98 ['Cache this.,application/json,1.0']98 ... print(key)
99 Cache this.,application/json,1.0
99100
100...UNLESS the representation being cached is for the version "cache101...UNLESS the representation being cached is for the version "cache
101everything!"102everything!"
@@ -206,7 +207,7 @@
206 >>> cookbook = [cookbook for cookbook in COOKBOOKS207 >>> cookbook = [cookbook for cookbook in COOKBOOKS
207 ... if cookbook.name == "Everyday Greens"][0]208 ... if cookbook.name == "Everyday Greens"][0]
208 >>> cache.set(cookbook, json, 'devel', "Dummy value.")209 >>> cache.set(cookbook, json, 'devel', "Dummy value.")
209 >>> print(dictionary.keys()[0])210 >>> print(list(dictionary.keys())[0])
210 http://.../devel/cookbooks/Everyday%20Greens,application/json211 http://.../devel/cookbooks/Everyday%20Greens,application/json
211212
212 >>> from six.moves.urllib.parse import quote213 >>> from six.moves.urllib.parse import quote
@@ -239,7 +240,7 @@
239240
240 >>> print(cache.get(recipe, json, 'devel'))241 >>> print(cache.get(recipe, json, 'devel'))
241 None242 None
242 >>> dictionary.keys()243 >>> list(dictionary)
243 []244 []
244245
245Data visibility246Data visibility
@@ -254,7 +255,7 @@
254 >>> print(greens['confirmed'])255 >>> print(greens['confirmed'])
255 tag:launchpad.net:2008:redacted256 tag:launchpad.net:2008:redacted
256257
257 >>> dictionary.keys()258 >>> list(dictionary)
258 []259 []
259260
260This means that if your entry resources typically contain data that's261This means that if your entry resources typically contain data that's
261262
=== modified file 'src/lazr/restful/metazcml.py'
--- src/lazr/restful/metazcml.py 2020-02-04 19:02:02 +0000
+++ src/lazr/restful/metazcml.py 2020-07-22 23:32:54 +0000
@@ -479,7 +479,7 @@
479 registered_adapters = set()479 registered_adapters = set()
480 block_mutator_operations = set()480 block_mutator_operations = set()
481481
482 methods = interface.namesAndDescriptions(True)482 methods = list(interface.namesAndDescriptions(True))
483 for iface in REGISTERED_CONTRIBUTORS[interface]:483 for iface in REGISTERED_CONTRIBUTORS[interface]:
484 methods.extend(iface.namesAndDescriptions(True))484 methods.extend(iface.namesAndDescriptions(True))
485485
486486
=== modified file 'src/lazr/restful/simple.py'
--- src/lazr/restful/simple.py 2020-02-04 13:17:32 +0000
+++ src/lazr/restful/simple.py 2020-07-22 23:32:54 +0000
@@ -207,7 +207,7 @@
207207
208 @property208 @property
209 def top_level_names(self):209 def top_level_names(self):
210 return self.top_level_objects.keys()210 return list(self.top_level_objects.keys())
211211
212 def get(self, request, name):212 def get(self, request, name):
213 """Traverse to a top-level object."""213 """Traverse to a top-level object."""
214214
=== modified file 'src/lazr/restful/tales.py'
--- src/lazr/restful/tales.py 2020-02-05 12:16:44 +0000
+++ src/lazr/restful/tales.py 2020-07-22 23:32:54 +0000
@@ -222,7 +222,7 @@
222 # iterate through attributes one at a time because some222 # iterate through attributes one at a time because some
223 # versions of docutils don't case-normalize attributes.223 # versions of docutils don't case-normalize attributes.
224 for attr_dict in attr_dicts:224 for attr_dict in attr_dicts:
225 for (key, val) in attr_dict.items():225 for (key, val) in list(attr_dict.items()):
226 # Prefix all CSS classes with "rst-"; and prefix all226 # Prefix all CSS classes with "rst-"; and prefix all
227 # names with "rst-" to avoid conflicts.227 # names with "rst-" to avoid conflicts.
228 if key.lower() in ('class', 'id', 'name'):228 if key.lower() in ('class', 'id', 'name'):
229229
=== modified file 'src/lazr/restful/tests/test_declarations.py'
--- src/lazr/restful/tests/test_declarations.py 2020-02-19 16:09:10 +0000
+++ src/lazr/restful/tests/test_declarations.py 2020-07-22 23:32:54 +0000
@@ -948,8 +948,8 @@
948 *self.utility.active_versions)948 *self.utility.active_versions)
949 interface_10 = interfaces[0].object949 interface_10 = interfaces[0].object
950 interface_20 = interfaces[1].object950 interface_20 = interfaces[1].object
951 self.assertEqual(interface_10.names(), ['field'])951 self.assertEqual(list(interface_10.names()), ['field'])
952 self.assertEqual(interface_20.names(), ['field'])952 self.assertEqual(list(interface_20.names()), ['field'])
953953
954 def test_field_exported_as_of_later_version_is_not_exported_in_earlier_versions(self):954 def test_field_exported_as_of_later_version_is_not_exported_in_earlier_versions(self):
955 # If you export a field as_of version 2.0, it's not present in955 # If you export a field as_of version 2.0, it's not present in
@@ -959,8 +959,8 @@
959 *self.utility.active_versions)959 *self.utility.active_versions)
960 interface_10 = interfaces[0].object960 interface_10 = interfaces[0].object
961 interface_20 = interfaces[1].object961 interface_20 = interfaces[1].object
962 self.assertEqual(interface_10.names(), [])962 self.assertEqual(list(interface_10.names()), [])
963 self.assertEqual(interface_20.names(), ['field'])963 self.assertEqual(list(interface_20.names()), ['field'])
964964
965 def test_field_not_exported_using_as_of_fails(self):965 def test_field_not_exported_using_as_of_fails(self):
966 # If you export a field without specifying as_of, you get an966 # If you export a field without specifying as_of, you get an

Subscribers

People subscribed via source and target branches