Merge lp:~leonardr/lazr.restful/no-latest-version into lp:lazr.restful

Proposed by Leonard Richardson
Status: Merged
Merged at revision: not available
Proposed branch: lp:~leonardr/lazr.restful/no-latest-version
Merge into: lp:lazr.restful
Diff against target: 340 lines (+35/-67)
18 files modified
src/lazr/restful/NEWS.txt (+8/-12)
src/lazr/restful/_resource.py (+1/-4)
src/lazr/restful/directives/__init__.py (+1/-2)
src/lazr/restful/docs/absoluteurl.txt (+3/-4)
src/lazr/restful/docs/multiversion.txt (+1/-2)
src/lazr/restful/docs/webservice-declarations.txt (+0/-1)
src/lazr/restful/docs/webservice-error.txt (+1/-1)
src/lazr/restful/docs/webservice.txt (+1/-2)
src/lazr/restful/example/base/root.py (+3/-3)
src/lazr/restful/example/base/tests/field.txt (+1/-1)
src/lazr/restful/example/base/tests/root.txt (+2/-2)
src/lazr/restful/example/base/tests/wadl.txt (+1/-1)
src/lazr/restful/example/multiversion/root.py (+1/-2)
src/lazr/restful/interfaces/_rest.py (+6/-20)
src/lazr/restful/metazcml.py (+1/-4)
src/lazr/restful/publisher.py (+2/-4)
src/lazr/restful/testing/webservice.py (+1/-1)
src/lazr/restful/tests/test_webservice.py (+1/-1)
To merge this branch: bzr merge lp:~leonardr/lazr.restful/no-latest-version
Reviewer Review Type Date Requested Status
Gary Poster Approve
Review via email: mp+19122@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) wrote :

This branch fixes bug 520542, removing the confusing "latest_version_uri_prefix" attribute from IWebServiceConfiguration and everywhere else. Now there is a single list of active_versions and if you want to have a floating dev version, it can go on the end of the active_versions list.

The changes to the tests happen because FakeRequest (used by the tests) by default made a request to the last version mentioned in active_versions, *not* the most recent version period. When 'devel' was in latest_version_uri_prefix, the last version mentioned in active_versions was '1.0'. Now it's 'devel', so some of the URLs in tests changed.

Revision history for this message
Gary Poster (gary) wrote :

Nice change.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/lazr/restful/NEWS.txt'
--- src/lazr/restful/NEWS.txt 2010-02-10 21:44:13 +0000
+++ src/lazr/restful/NEWS.txt 2010-02-11 18:16:16 +0000
@@ -7,8 +7,7 @@
77
8Special note: this version contains backwards-incompatible8Special note: this version contains backwards-incompatible
9changes. You *must* change your configuration object to get your code9changes. You *must* change your configuration object to get your code
10to work in this version! See "active_versions" and10to work in this version! See "active_versions" below.
11"latest_version_uri_prefix" below.
1211
13Added a versioning system for web services. Clients can now request12Added a versioning system for web services. Clients can now request
14any number of distinct versions as well as a floating "trunk" which is13any number of distinct versions as well as a floating "trunk" which is
@@ -17,17 +16,14 @@
17the example web service in example/multiversion/ to see how the16the example web service in example/multiversion/ to see how the
18annotations work.17annotations work.
1918
20This release introduces a new field to IWebServiceConfiguration:
21latest_version_uri_prefix. If you are rolling your own
22IWebServiceConfiguration implementation, rather than subclassing from
23BaseWebServiceConfiguration or one of its subclasses, you'll need to
24set a value for this.
25
26This release _replaces_ one of the fields in19This release _replaces_ one of the fields in
27IWebServiceConfiguration. The string service_version_uri_prefix has20IWebServiceConfiguration. The string 'service_version_uri'_prefix has
28become the list active_versions. The simplest way to deal with this is21become the list 'active_versions'. The simplest way to deal with this is
29to just put your service_version_uri_prefix into a list and call it22to just put your 'service_version_uri_prefix' into a list and call it
30active_versions.23'active_versions'. We recommend you also add a floating "development"
24version to the end of 'active_versions', calling it something like
25"devel" or "trunk". This will give your users a permanent alias to
26"the most recent version of the web service".
3127
320.9.17 (2009-11-10)280.9.17 (2009-11-10)
33===================29===================
3430
=== modified file 'src/lazr/restful/_resource.py'
--- src/lazr/restful/_resource.py 2010-02-11 16:32:17 +0000
+++ src/lazr/restful/_resource.py 2010-02-11 18:16:16 +0000
@@ -1601,10 +1601,7 @@
16011601
1602 # Determine the name of the earliest version. We'll be using this later.1602 # Determine the name of the earliest version. We'll be using this later.
1603 config = getUtility(IWebServiceConfiguration)1603 config = getUtility(IWebServiceConfiguration)
1604 if len(config.active_versions) > 0:1604 earliest_version = config.active_versions[0]
1605 earliest_version = config.active_versions[0]
1606 else:
1607 earliest_version = config.latest_version_uri_prefix
16081605
1609 for registration in sorted(site_manager.registeredAdapters()):1606 for registration in sorted(site_manager.registeredAdapters()):
1610 provided = registration.provided1607 provided = registration.provided
16111608
=== modified file 'src/lazr/restful/directives/__init__.py'
--- src/lazr/restful/directives/__init__.py 2010-02-03 15:24:00 +0000
+++ src/lazr/restful/directives/__init__.py 2010-02-11 18:16:16 +0000
@@ -99,8 +99,7 @@
9999
100 # Create and register marker interfaces for request objects.100 # Create and register marker interfaces for request objects.
101 superclass = IWebServiceClientRequest101 superclass = IWebServiceClientRequest
102 for version in (102 for version in (utility.active_versions):
103 utility.active_versions + [utility.latest_version_uri_prefix]):
104 name_part = make_identifier_safe(version)103 name_part = make_identifier_safe(version)
105 if not name_part.startswith('_'):104 if not name_part.startswith('_'):
106 name_part = '_' + name_part105 name_part = '_' + name_part
107106
=== modified file 'src/lazr/restful/docs/absoluteurl.txt'
--- src/lazr/restful/docs/absoluteurl.txt 2009-11-12 19:08:10 +0000
+++ src/lazr/restful/docs/absoluteurl.txt 2010-02-11 18:16:16 +0000
@@ -29,8 +29,7 @@
29 ... implements(IWebServiceConfiguration)29 ... implements(IWebServiceConfiguration)
30 ... hostname = "hostname"30 ... hostname = "hostname"
31 ... service_root_uri_prefix = "root_uri_prefix/"31 ... service_root_uri_prefix = "root_uri_prefix/"
32 ... active_versions = ['active_version']32 ... active_versions = ['active_version', 'latest_version']
33 ... latest_version_uri_prefix = "latest_version_uri_prefix"
34 ... port = 100033 ... port = 1000
35 ... use_https = True34 ... use_https = True
3635
@@ -85,10 +84,10 @@
85value of the 'lazr.restful.version' annotation.84value of the 'lazr.restful.version' annotation.
8685
87 >>> request.annotations[request.VERSION_ANNOTATION] = (86 >>> request.annotations[request.VERSION_ANNOTATION] = (
88 ... 'latest_version_uri_prefix')87 ... 'latest_version')
89 >>> adapter = getMultiAdapter((resource, request), IAbsoluteURL)88 >>> adapter = getMultiAdapter((resource, request), IAbsoluteURL)
90 >>> print adapter()89 >>> print adapter()
91 http://hostname/root_uri_prefix/latest_version_uri_prefix/90 http://hostname/root_uri_prefix/latest_version/
9291
93For purposes of URL generation, the annotation doesn't have to be a92For purposes of URL generation, the annotation doesn't have to be a
94real version defined by the web service. Any string will do.93real version defined by the web service. Any string will do.
9594
=== modified file 'src/lazr/restful/docs/multiversion.txt'
--- src/lazr/restful/docs/multiversion.txt 2010-01-26 17:00:23 +0000
+++ src/lazr/restful/docs/multiversion.txt 2010-02-11 18:16:16 +0000
@@ -39,8 +39,7 @@
39 >>> class WebServiceConfiguration(BaseWebServiceConfiguration):39 >>> class WebServiceConfiguration(BaseWebServiceConfiguration):
40 ... hostname = 'api.multiversion.dev'40 ... hostname = 'api.multiversion.dev'
41 ... use_https = False41 ... use_https = False
42 ... active_versions = ['beta', '1.0']42 ... active_versions = ['beta', '1.0', 'dev']
43 ... latest_version_uri_prefix = 'dev'
44 ... code_revision = 'test'43 ... code_revision = 'test'
45 ... max_batch_size = 10044 ... max_batch_size = 100
46 ... view_permission = None45 ... view_permission = None
4746
=== modified file 'src/lazr/restful/docs/webservice-declarations.txt'
--- src/lazr/restful/docs/webservice-declarations.txt 2010-02-08 18:24:57 +0000
+++ src/lazr/restful/docs/webservice-declarations.txt 2010-02-11 18:16:16 +0000
@@ -905,7 +905,6 @@
905 ... active_versions = ["beta", "1.0", "2.0", "3.0"]905 ... active_versions = ["beta", "1.0", "2.0", "3.0"]
906 ... code_revision = "1.0b"906 ... code_revision = "1.0b"
907 ... default_batch_size = 50907 ... default_batch_size = 50
908 ... latest_version_uri_prefix = '3.0'
909 ...908 ...
910 ... def get_request_user(self):909 ... def get_request_user(self):
911 ... return 'A user'910 ... return 'A user'
912911
=== modified file 'src/lazr/restful/docs/webservice-error.txt'
--- src/lazr/restful/docs/webservice-error.txt 2010-02-03 16:19:03 +0000
+++ src/lazr/restful/docs/webservice-error.txt 2010-02-11 18:16:16 +0000
@@ -16,7 +16,7 @@
16 >>> class SimpleWebServiceConfiguration:16 >>> class SimpleWebServiceConfiguration:
17 ... implements(IWebServiceConfiguration)17 ... implements(IWebServiceConfiguration)
18 ... show_tracebacks = False18 ... show_tracebacks = False
19 ... latest_version_uri_prefix = 'trunk'19 ... active_versions = ['trunk']
20 >>> webservice_configuration = SimpleWebServiceConfiguration()20 >>> webservice_configuration = SimpleWebServiceConfiguration()
21 >>> sm.registerUtility(webservice_configuration)21 >>> sm.registerUtility(webservice_configuration)
2222
2323
=== modified file 'src/lazr/restful/docs/webservice.txt'
--- src/lazr/restful/docs/webservice.txt 2010-02-11 14:44:16 +0000
+++ src/lazr/restful/docs/webservice.txt 2010-02-11 18:16:16 +0000
@@ -500,8 +500,7 @@
500 >>> class WebServiceConfiguration(BaseWebServiceConfiguration):500 >>> class WebServiceConfiguration(BaseWebServiceConfiguration):
501 ... hostname = 'api.cookbooks.dev'501 ... hostname = 'api.cookbooks.dev'
502 ... use_https = False502 ... use_https = False
503 ... active_versions = ['beta']503 ... active_versions = ['beta', 'devel']
504 ... latest_version_uri_prefix = 'devel'
505 ... code_revision = 'test'504 ... code_revision = 'test'
506 ... max_batch_size = 100505 ... max_batch_size = 100
507 ... directives.publication_class(WebServiceTestPublication)506 ... directives.publication_class(WebServiceTestPublication)
508507
=== modified file 'src/lazr/restful/example/base/root.py'
--- src/lazr/restful/example/base/root.py 2010-01-04 21:45:14 +0000
+++ src/lazr/restful/example/base/root.py 2010-02-11 18:16:16 +0000
@@ -64,14 +64,14 @@
64 def alias_url(self):64 def alias_url(self):
65 """The URL to the managed file.65 """The URL to the managed file.
6666
67 This URL will always contain the latest_version_uri_prefix, no67 This URL will always contain the name of the latest version, no
68 matter the version of the original request. This is not ideal,68 matter the version of the original request. This is not ideal,
69 but it's acceptable because 1) this is just a test69 but it's acceptable because 1) this is just a test
70 implementation, and 2) the ByteStorage implementation cannot70 implementation, and 2) the ByteStorage implementation cannot
71 change between versions.71 change between versions.
72 """72 """
73 return 'http://cookbooks.dev/%s/filemanager/%s' % (73 return 'http://cookbooks.dev/%s/filemanager/%s' % (
74 getUtility(IWebServiceConfiguration).latest_version_uri_prefix,74 getUtility(IWebServiceConfiguration).active_versions[-1],
75 self.id)75 self.id)
7676
77 def createStored(self, mediaType, representation, filename=None):77 def createStored(self, mediaType, representation, filename=None):
@@ -388,7 +388,7 @@
388 default_batch_size=5388 default_batch_size=5
389 hostname='cookbooks.dev'389 hostname='cookbooks.dev'
390 match_batch_size=50390 match_batch_size=50
391 active_versions=['1.0']391 active_versions=['1.0', 'devel']
392 use_https=False392 use_https=False
393 view_permission='lazr.restful.example.base.View'393 view_permission='lazr.restful.example.base.View'
394394
395395
=== modified file 'src/lazr/restful/example/base/tests/field.txt'
--- src/lazr/restful/example/base/tests/field.txt 2009-09-25 13:36:31 +0000
+++ src/lazr/restful/example/base/tests/field.txt 2010-02-11 18:16:16 +0000
@@ -61,7 +61,7 @@
61 Content-Type: application/json61 Content-Type: application/json
62 ...62 ...
63 <BLANKLINE>63 <BLANKLINE>
64 "http://cookbooks.dev/1.0/cookbooks/The%20Joy%20of%20Cooking"64 "http://cookbooks.dev/.../cookbooks/The%20Joy%20of%20Cooking"
6565
66The same rules for modifying a field apply whether you're modifying66The same rules for modifying a field apply whether you're modifying
67the entry as a whole or just modifying a single field.67the entry as a whole or just modifying a single field.
6868
=== modified file 'src/lazr/restful/example/base/tests/root.txt'
--- src/lazr/restful/example/base/tests/root.txt 2009-11-12 16:30:50 +0000
+++ src/lazr/restful/example/base/tests/root.txt 2010-02-11 18:16:16 +0000
@@ -15,10 +15,10 @@
15 u'featured_cookbook_link', u'recipes_collection_link',15 u'featured_cookbook_link', u'recipes_collection_link',
16 u'resource_type_link']16 u'resource_type_link']
17 >>> top_level_links['cookbooks_collection_link']17 >>> top_level_links['cookbooks_collection_link']
18 u'http://cookbooks.dev/1.0/cookbooks'18 u'http://cookbooks.dev/devel/cookbooks'
1919
20 >>> print top_level_links['resource_type_link']20 >>> print top_level_links['resource_type_link']
21 http://cookbooks.dev/1.0/#service-root21 http://cookbooks.dev/devel/#service-root
2222
23The client can explore the entire web service by following these links23The client can explore the entire web service by following these links
24to other resources, and following the links served in those resources'24to other resources, and following the links served in those resources'
2525
=== modified file 'src/lazr/restful/example/base/tests/wadl.txt'
--- src/lazr/restful/example/base/tests/wadl.txt 2009-10-21 14:10:49 +0000
+++ src/lazr/restful/example/base/tests/wadl.txt 2010-02-11 18:16:16 +0000
@@ -381,7 +381,7 @@
381 >>> resources.tag381 >>> resources.tag
382 '...resources'382 '...resources'
383 >>> print resources.attrib['base']383 >>> print resources.attrib['base']
384 http://cookbooks.dev/1.0/384 http://cookbooks.dev/devel/
385385
386As with the <resources> tags shown earlier, this one contains a single386As with the <resources> tags shown earlier, this one contains a single
387<resource> tag.387<resource> tag.
388388
=== modified file 'src/lazr/restful/example/multiversion/root.py'
--- src/lazr/restful/example/multiversion/root.py 2010-02-08 18:24:57 +0000
+++ src/lazr/restful/example/multiversion/root.py 2010-02-11 18:16:16 +0000
@@ -34,8 +34,7 @@
3434
35class WebServiceConfiguration(BaseWSGIWebServiceConfiguration):35class WebServiceConfiguration(BaseWSGIWebServiceConfiguration):
36 code_revision = '1'36 code_revision = '1'
37 active_versions = ['beta', '1.0', '2.0', '3.0']37 active_versions = ['beta', '1.0', '2.0', '3.0', 'trunk']
38 latest_version_uri_prefix = 'trunk'
39 use_https = False38 use_https = False
40 view_permission = 'zope.Public'39 view_permission = 'zope.Public'
4140
4241
=== modified file 'src/lazr/restful/interfaces/_rest.py'
--- src/lazr/restful/interfaces/_rest.py 2010-02-11 16:32:17 +0000
+++ src/lazr/restful/interfaces/_rest.py 2010-02-11 18:16:16 +0000
@@ -441,26 +441,12 @@
441 "beta", or the date a particular version was finalized.441 "beta", or the date a particular version was finalized.
442442
443 Newer versions should show up later in the list than earlier443 Newer versions should show up later in the list than earlier
444 versions. The most recent active version should be at the end444 versions. It's recommended that the last version, located at
445 of the list.445 the end of the list, be a floating development version called
446446 something like 'trunk' or 'devel': effectively an alias for
447 Currently this list must contain at least one version name.""")447 "the most up-to-date code".
448448
449 # XXX 2010-02-11 leonardr bug=520542: The latest version should449 This list must contain at least one version name.""")
450 # simply be the last version in active_versions.
451 latest_version_uri_prefix = TextLine(
452 default=u"devel",
453 description=u"""A string naming the alias for the "development"
454 version of a multi-versioned web service. This version may
455 have features not present in older versions, and may be
456 backwards incompatible with those services, but it is not
457 necessarily the same as any released version. If you do not
458 publish a multi-versioned web service, just use the default.
459
460 latest_version_uri_prefix shows up in the same place as any
461 other version URI prefix: after any value for
462 service_root_uri_prefix.
463 """)
464450
465 code_revision = TextLine(451 code_revision = TextLine(
466 default=u"",452 default=u"",
467453
=== modified file 'src/lazr/restful/metazcml.py'
--- src/lazr/restful/metazcml.py 2010-02-03 17:40:54 +0000
+++ src/lazr/restful/metazcml.py 2010-02-11 18:16:16 +0000
@@ -46,8 +46,6 @@
46 # Get the list of versions.46 # Get the list of versions.
47 config = getUtility(IWebServiceConfiguration)47 config = getUtility(IWebServiceConfiguration)
48 versions = list(config.active_versions)48 versions = list(config.active_versions)
49 if config.latest_version_uri_prefix not in versions:
50 versions += [config.latest_version_uri_prefix]
5149
52 # Generate an interface and an adapter for every version.50 # Generate an interface and an adapter for every version.
53 web_interfaces = generate_entry_interfaces(interface, *versions)51 web_interfaces = generate_entry_interfaces(interface, *versions)
@@ -86,8 +84,7 @@
86 versions.84 versions.
87 """85 """
88 configuration = getUtility(IWebServiceConfiguration)86 configuration = getUtility(IWebServiceConfiguration)
89 actual_versions = configuration.active_versions + [87 actual_versions = configuration.active_versions
90 configuration.latest_version_uri_prefix]
91 # Replace None with the actual version number of the earliest88 # Replace None with the actual version number of the earliest
92 # version.89 # version.
93 try:90 try:
9491
=== modified file 'src/lazr/restful/publisher.py'
--- src/lazr/restful/publisher.py 2010-01-11 18:27:43 +0000
+++ src/lazr/restful/publisher.py 2010-02-11 18:16:16 +0000
@@ -241,12 +241,10 @@
241 # optimizations later in the request lifecycle.241 # optimizations later in the request lifecycle.
242 alsoProvides(self, IWebBrowserInitiatedRequest)242 alsoProvides(self, IWebBrowserInitiatedRequest)
243243
244 # Only accept versioned URLs. Either the244 # Only accept versioned URLs. Any of the active_versions is
245 # latest_version_uri_prefix or one of the active_versions is
246 # acceptable.245 # acceptable.
247 version = None246 version = None
248 for version_string in (247 for version_string in config.active_versions:
249 config.active_versions + [config.latest_version_uri_prefix]):
250 if version_string is not None:248 if version_string is not None:
251 version = self._popTraversal(version_string)249 version = self._popTraversal(version_string)
252 if version is not None:250 if version is not None:
253251
=== modified file 'src/lazr/restful/testing/webservice.py'
--- src/lazr/restful/testing/webservice.py 2010-02-03 16:19:03 +0000
+++ src/lazr/restful/testing/webservice.py 2010-02-11 18:16:16 +0000
@@ -107,7 +107,7 @@
107 def __init__(self, traversed=None, stack=None, version=None):107 def __init__(self, traversed=None, stack=None, version=None):
108 if version is None:108 if version is None:
109 config = getUtility(IWebServiceConfiguration)109 config = getUtility(IWebServiceConfiguration)
110 version = config.latest_version_uri_prefix110 version = config.active_versions[-1]
111 self.version = version111 self.version = version
112 self._traversed_names = traversed112 self._traversed_names = traversed
113 self._stack = stack113 self._stack = stack
114114
=== modified file 'src/lazr/restful/tests/test_webservice.py'
--- src/lazr/restful/tests/test_webservice.py 2010-02-01 16:08:58 +0000
+++ src/lazr/restful/tests/test_webservice.py 2010-02-11 18:16:16 +0000
@@ -98,7 +98,7 @@
98class SimpleWebServiceConfiguration(BaseWebServiceConfiguration):98class SimpleWebServiceConfiguration(BaseWebServiceConfiguration):
99 implements(IWebServiceConfiguration)99 implements(IWebServiceConfiguration)
100 show_tracebacks = False100 show_tracebacks = False
101 latest_version_uri_prefix = 'trunk'101 active_versions = ['trunk']
102 hostname = "webservice_test"102 hostname = "webservice_test"
103103
104 def createRequest(self, body_instream, environ):104 def createRequest(self, body_instream, environ):

Subscribers

People subscribed via source and target branches