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
1=== modified file 'src/lazr/restful/NEWS.txt'
2--- src/lazr/restful/NEWS.txt 2010-02-10 21:44:13 +0000
3+++ src/lazr/restful/NEWS.txt 2010-02-11 18:16:16 +0000
4@@ -7,8 +7,7 @@
5
6 Special note: this version contains backwards-incompatible
7 changes. You *must* change your configuration object to get your code
8-to work in this version! See "active_versions" and
9-"latest_version_uri_prefix" below.
10+to work in this version! See "active_versions" below.
11
12 Added a versioning system for web services. Clients can now request
13 any number of distinct versions as well as a floating "trunk" which is
14@@ -17,17 +16,14 @@
15 the example web service in example/multiversion/ to see how the
16 annotations work.
17
18-This release introduces a new field to IWebServiceConfiguration:
19-latest_version_uri_prefix. If you are rolling your own
20-IWebServiceConfiguration implementation, rather than subclassing from
21-BaseWebServiceConfiguration or one of its subclasses, you'll need to
22-set a value for this.
23-
24 This release _replaces_ one of the fields in
25-IWebServiceConfiguration. The string service_version_uri_prefix has
26-become the list active_versions. The simplest way to deal with this is
27-to just put your service_version_uri_prefix into a list and call it
28-active_versions.
29+IWebServiceConfiguration. The string 'service_version_uri'_prefix has
30+become the list 'active_versions'. The simplest way to deal with this is
31+to just put your 'service_version_uri_prefix' into a list and call it
32+'active_versions'. We recommend you also add a floating "development"
33+version to the end of 'active_versions', calling it something like
34+"devel" or "trunk". This will give your users a permanent alias to
35+"the most recent version of the web service".
36
37 0.9.17 (2009-11-10)
38 ===================
39
40=== modified file 'src/lazr/restful/_resource.py'
41--- src/lazr/restful/_resource.py 2010-02-11 16:32:17 +0000
42+++ src/lazr/restful/_resource.py 2010-02-11 18:16:16 +0000
43@@ -1601,10 +1601,7 @@
44
45 # Determine the name of the earliest version. We'll be using this later.
46 config = getUtility(IWebServiceConfiguration)
47- if len(config.active_versions) > 0:
48- earliest_version = config.active_versions[0]
49- else:
50- earliest_version = config.latest_version_uri_prefix
51+ earliest_version = config.active_versions[0]
52
53 for registration in sorted(site_manager.registeredAdapters()):
54 provided = registration.provided
55
56=== modified file 'src/lazr/restful/directives/__init__.py'
57--- src/lazr/restful/directives/__init__.py 2010-02-03 15:24:00 +0000
58+++ src/lazr/restful/directives/__init__.py 2010-02-11 18:16:16 +0000
59@@ -99,8 +99,7 @@
60
61 # Create and register marker interfaces for request objects.
62 superclass = IWebServiceClientRequest
63- for version in (
64- utility.active_versions + [utility.latest_version_uri_prefix]):
65+ for version in (utility.active_versions):
66 name_part = make_identifier_safe(version)
67 if not name_part.startswith('_'):
68 name_part = '_' + name_part
69
70=== modified file 'src/lazr/restful/docs/absoluteurl.txt'
71--- src/lazr/restful/docs/absoluteurl.txt 2009-11-12 19:08:10 +0000
72+++ src/lazr/restful/docs/absoluteurl.txt 2010-02-11 18:16:16 +0000
73@@ -29,8 +29,7 @@
74 ... implements(IWebServiceConfiguration)
75 ... hostname = "hostname"
76 ... service_root_uri_prefix = "root_uri_prefix/"
77- ... active_versions = ['active_version']
78- ... latest_version_uri_prefix = "latest_version_uri_prefix"
79+ ... active_versions = ['active_version', 'latest_version']
80 ... port = 1000
81 ... use_https = True
82
83@@ -85,10 +84,10 @@
84 value of the 'lazr.restful.version' annotation.
85
86 >>> request.annotations[request.VERSION_ANNOTATION] = (
87- ... 'latest_version_uri_prefix')
88+ ... 'latest_version')
89 >>> adapter = getMultiAdapter((resource, request), IAbsoluteURL)
90 >>> print adapter()
91- http://hostname/root_uri_prefix/latest_version_uri_prefix/
92+ http://hostname/root_uri_prefix/latest_version/
93
94 For purposes of URL generation, the annotation doesn't have to be a
95 real version defined by the web service. Any string will do.
96
97=== modified file 'src/lazr/restful/docs/multiversion.txt'
98--- src/lazr/restful/docs/multiversion.txt 2010-01-26 17:00:23 +0000
99+++ src/lazr/restful/docs/multiversion.txt 2010-02-11 18:16:16 +0000
100@@ -39,8 +39,7 @@
101 >>> class WebServiceConfiguration(BaseWebServiceConfiguration):
102 ... hostname = 'api.multiversion.dev'
103 ... use_https = False
104- ... active_versions = ['beta', '1.0']
105- ... latest_version_uri_prefix = 'dev'
106+ ... active_versions = ['beta', '1.0', 'dev']
107 ... code_revision = 'test'
108 ... max_batch_size = 100
109 ... view_permission = None
110
111=== modified file 'src/lazr/restful/docs/webservice-declarations.txt'
112--- src/lazr/restful/docs/webservice-declarations.txt 2010-02-08 18:24:57 +0000
113+++ src/lazr/restful/docs/webservice-declarations.txt 2010-02-11 18:16:16 +0000
114@@ -905,7 +905,6 @@
115 ... active_versions = ["beta", "1.0", "2.0", "3.0"]
116 ... code_revision = "1.0b"
117 ... default_batch_size = 50
118- ... latest_version_uri_prefix = '3.0'
119 ...
120 ... def get_request_user(self):
121 ... return 'A user'
122
123=== modified file 'src/lazr/restful/docs/webservice-error.txt'
124--- src/lazr/restful/docs/webservice-error.txt 2010-02-03 16:19:03 +0000
125+++ src/lazr/restful/docs/webservice-error.txt 2010-02-11 18:16:16 +0000
126@@ -16,7 +16,7 @@
127 >>> class SimpleWebServiceConfiguration:
128 ... implements(IWebServiceConfiguration)
129 ... show_tracebacks = False
130- ... latest_version_uri_prefix = 'trunk'
131+ ... active_versions = ['trunk']
132 >>> webservice_configuration = SimpleWebServiceConfiguration()
133 >>> sm.registerUtility(webservice_configuration)
134
135
136=== modified file 'src/lazr/restful/docs/webservice.txt'
137--- src/lazr/restful/docs/webservice.txt 2010-02-11 14:44:16 +0000
138+++ src/lazr/restful/docs/webservice.txt 2010-02-11 18:16:16 +0000
139@@ -500,8 +500,7 @@
140 >>> class WebServiceConfiguration(BaseWebServiceConfiguration):
141 ... hostname = 'api.cookbooks.dev'
142 ... use_https = False
143- ... active_versions = ['beta']
144- ... latest_version_uri_prefix = 'devel'
145+ ... active_versions = ['beta', 'devel']
146 ... code_revision = 'test'
147 ... max_batch_size = 100
148 ... directives.publication_class(WebServiceTestPublication)
149
150=== modified file 'src/lazr/restful/example/base/root.py'
151--- src/lazr/restful/example/base/root.py 2010-01-04 21:45:14 +0000
152+++ src/lazr/restful/example/base/root.py 2010-02-11 18:16:16 +0000
153@@ -64,14 +64,14 @@
154 def alias_url(self):
155 """The URL to the managed file.
156
157- This URL will always contain the latest_version_uri_prefix, no
158+ This URL will always contain the name of the latest version, no
159 matter the version of the original request. This is not ideal,
160 but it's acceptable because 1) this is just a test
161 implementation, and 2) the ByteStorage implementation cannot
162 change between versions.
163 """
164 return 'http://cookbooks.dev/%s/filemanager/%s' % (
165- getUtility(IWebServiceConfiguration).latest_version_uri_prefix,
166+ getUtility(IWebServiceConfiguration).active_versions[-1],
167 self.id)
168
169 def createStored(self, mediaType, representation, filename=None):
170@@ -388,7 +388,7 @@
171 default_batch_size=5
172 hostname='cookbooks.dev'
173 match_batch_size=50
174- active_versions=['1.0']
175+ active_versions=['1.0', 'devel']
176 use_https=False
177 view_permission='lazr.restful.example.base.View'
178
179
180=== modified file 'src/lazr/restful/example/base/tests/field.txt'
181--- src/lazr/restful/example/base/tests/field.txt 2009-09-25 13:36:31 +0000
182+++ src/lazr/restful/example/base/tests/field.txt 2010-02-11 18:16:16 +0000
183@@ -61,7 +61,7 @@
184 Content-Type: application/json
185 ...
186 <BLANKLINE>
187- "http://cookbooks.dev/1.0/cookbooks/The%20Joy%20of%20Cooking"
188+ "http://cookbooks.dev/.../cookbooks/The%20Joy%20of%20Cooking"
189
190 The same rules for modifying a field apply whether you're modifying
191 the entry as a whole or just modifying a single field.
192
193=== modified file 'src/lazr/restful/example/base/tests/root.txt'
194--- src/lazr/restful/example/base/tests/root.txt 2009-11-12 16:30:50 +0000
195+++ src/lazr/restful/example/base/tests/root.txt 2010-02-11 18:16:16 +0000
196@@ -15,10 +15,10 @@
197 u'featured_cookbook_link', u'recipes_collection_link',
198 u'resource_type_link']
199 >>> top_level_links['cookbooks_collection_link']
200- u'http://cookbooks.dev/1.0/cookbooks'
201+ u'http://cookbooks.dev/devel/cookbooks'
202
203 >>> print top_level_links['resource_type_link']
204- http://cookbooks.dev/1.0/#service-root
205+ http://cookbooks.dev/devel/#service-root
206
207 The client can explore the entire web service by following these links
208 to other resources, and following the links served in those resources'
209
210=== modified file 'src/lazr/restful/example/base/tests/wadl.txt'
211--- src/lazr/restful/example/base/tests/wadl.txt 2009-10-21 14:10:49 +0000
212+++ src/lazr/restful/example/base/tests/wadl.txt 2010-02-11 18:16:16 +0000
213@@ -381,7 +381,7 @@
214 >>> resources.tag
215 '...resources'
216 >>> print resources.attrib['base']
217- http://cookbooks.dev/1.0/
218+ http://cookbooks.dev/devel/
219
220 As with the <resources> tags shown earlier, this one contains a single
221 <resource> tag.
222
223=== modified file 'src/lazr/restful/example/multiversion/root.py'
224--- src/lazr/restful/example/multiversion/root.py 2010-02-08 18:24:57 +0000
225+++ src/lazr/restful/example/multiversion/root.py 2010-02-11 18:16:16 +0000
226@@ -34,8 +34,7 @@
227
228 class WebServiceConfiguration(BaseWSGIWebServiceConfiguration):
229 code_revision = '1'
230- active_versions = ['beta', '1.0', '2.0', '3.0']
231- latest_version_uri_prefix = 'trunk'
232+ active_versions = ['beta', '1.0', '2.0', '3.0', 'trunk']
233 use_https = False
234 view_permission = 'zope.Public'
235
236
237=== modified file 'src/lazr/restful/interfaces/_rest.py'
238--- src/lazr/restful/interfaces/_rest.py 2010-02-11 16:32:17 +0000
239+++ src/lazr/restful/interfaces/_rest.py 2010-02-11 18:16:16 +0000
240@@ -441,26 +441,12 @@
241 "beta", or the date a particular version was finalized.
242
243 Newer versions should show up later in the list than earlier
244- versions. The most recent active version should be at the end
245- of the list.
246-
247- Currently this list must contain at least one version name.""")
248-
249- # XXX 2010-02-11 leonardr bug=520542: The latest version should
250- # simply be the last version in active_versions.
251- latest_version_uri_prefix = TextLine(
252- default=u"devel",
253- description=u"""A string naming the alias for the "development"
254- version of a multi-versioned web service. This version may
255- have features not present in older versions, and may be
256- backwards incompatible with those services, but it is not
257- necessarily the same as any released version. If you do not
258- publish a multi-versioned web service, just use the default.
259-
260- latest_version_uri_prefix shows up in the same place as any
261- other version URI prefix: after any value for
262- service_root_uri_prefix.
263- """)
264+ versions. It's recommended that the last version, located at
265+ the end of the list, be a floating development version called
266+ something like 'trunk' or 'devel': effectively an alias for
267+ "the most up-to-date code".
268+
269+ This list must contain at least one version name.""")
270
271 code_revision = TextLine(
272 default=u"",
273
274=== modified file 'src/lazr/restful/metazcml.py'
275--- src/lazr/restful/metazcml.py 2010-02-03 17:40:54 +0000
276+++ src/lazr/restful/metazcml.py 2010-02-11 18:16:16 +0000
277@@ -46,8 +46,6 @@
278 # Get the list of versions.
279 config = getUtility(IWebServiceConfiguration)
280 versions = list(config.active_versions)
281- if config.latest_version_uri_prefix not in versions:
282- versions += [config.latest_version_uri_prefix]
283
284 # Generate an interface and an adapter for every version.
285 web_interfaces = generate_entry_interfaces(interface, *versions)
286@@ -86,8 +84,7 @@
287 versions.
288 """
289 configuration = getUtility(IWebServiceConfiguration)
290- actual_versions = configuration.active_versions + [
291- configuration.latest_version_uri_prefix]
292+ actual_versions = configuration.active_versions
293 # Replace None with the actual version number of the earliest
294 # version.
295 try:
296
297=== modified file 'src/lazr/restful/publisher.py'
298--- src/lazr/restful/publisher.py 2010-01-11 18:27:43 +0000
299+++ src/lazr/restful/publisher.py 2010-02-11 18:16:16 +0000
300@@ -241,12 +241,10 @@
301 # optimizations later in the request lifecycle.
302 alsoProvides(self, IWebBrowserInitiatedRequest)
303
304- # Only accept versioned URLs. Either the
305- # latest_version_uri_prefix or one of the active_versions is
306+ # Only accept versioned URLs. Any of the active_versions is
307 # acceptable.
308 version = None
309- for version_string in (
310- config.active_versions + [config.latest_version_uri_prefix]):
311+ for version_string in config.active_versions:
312 if version_string is not None:
313 version = self._popTraversal(version_string)
314 if version is not None:
315
316=== modified file 'src/lazr/restful/testing/webservice.py'
317--- src/lazr/restful/testing/webservice.py 2010-02-03 16:19:03 +0000
318+++ src/lazr/restful/testing/webservice.py 2010-02-11 18:16:16 +0000
319@@ -107,7 +107,7 @@
320 def __init__(self, traversed=None, stack=None, version=None):
321 if version is None:
322 config = getUtility(IWebServiceConfiguration)
323- version = config.latest_version_uri_prefix
324+ version = config.active_versions[-1]
325 self.version = version
326 self._traversed_names = traversed
327 self._stack = stack
328
329=== modified file 'src/lazr/restful/tests/test_webservice.py'
330--- src/lazr/restful/tests/test_webservice.py 2010-02-01 16:08:58 +0000
331+++ src/lazr/restful/tests/test_webservice.py 2010-02-11 18:16:16 +0000
332@@ -98,7 +98,7 @@
333 class SimpleWebServiceConfiguration(BaseWebServiceConfiguration):
334 implements(IWebServiceConfiguration)
335 show_tracebacks = False
336- latest_version_uri_prefix = 'trunk'
337+ active_versions = ['trunk']
338 hostname = "webservice_test"
339
340 def createRequest(self, body_instream, environ):

Subscribers

People subscribed via source and target branches