Merge lp:~leonardr/launchpad/multiversion-wadl into lp:launchpad/db-devel

Proposed by Leonard Richardson
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~leonardr/launchpad/multiversion-wadl
Merge into: lp:launchpad/db-devel
Diff against target: 483 lines (+168/-95)
9 files modified
Makefile (+17/-9)
configs/development/launchpad-lazr.conf (+1/-1)
configs/testrunner-appserver/launchpad-lazr.conf (+1/-1)
configs/testrunner/launchpad-lazr.conf (+1/-1)
lib/canonical/launchpad/doc/webapp-publication.txt (+1/-1)
lib/canonical/launchpad/pagetests/webservice/xx-wadl.txt (+43/-17)
lib/canonical/launchpad/systemhomes.py (+35/-32)
lib/lp/code/stories/webservice/xx-branchmergeproposal.txt (+37/-18)
utilities/create-lp-wadl.py (+32/-15)
To merge this branch: bzr merge lp:~leonardr/launchpad/multiversion-wadl
Reviewer Review Type Date Requested Status
Gary Poster (community) Approve
Tim Penhey (community) release-critical Approve
Review via email: mp+20405@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) wrote :

This branch changes the build process so that it generates a static WADL file for every version of the web service, not just one file. There were a number of parts of this system that I didn't understand and might not be necessary anymore (mainly the fake 'development' WADL file, which only seems to get in the way), but I left them alone rather than make this branch more complex.

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

Thank you, Leonard.

review: Approve
Revision history for this message
Tim Penhey (thumper) :
review: Approve (release-critical)
Revision history for this message
Leonard Richardson (leonardr) wrote :

This needs another review. Two tests failed when I ran the ec2 suite. Both of them were fallout from when I changed the 'api' vhost's root url from "http://api.launchpad.dev/beta/" to "http://api.launchpad.dev/".

The fix to webapp-publication.txt was trivial. The fix to xx-branchmergeproposal.txt was not. canonical_url() had no idea how to incorporate the version of a web service request, and the test wasn't specifying which version of the web service was desired. I had to make canonical_url work when passed a versioned web service request, and then change the test to create a versioned request and pass it into canonical_url.

ec2 test is running again and will hopefully come up roses in the morning.

Revision history for this message
Leonard Richardson (leonardr) wrote :
Revision history for this message
Leonard Richardson (leonardr) wrote :

OK, one more. My earlier fix to xx-branchmergeproposal broke a whole lot of other tests because it changed the ways all URLs were generated, just for the sake of one test. This update reverts the change to canonical_url() and instead changes xx-branchmergeproposal to use the standard way of generating web service URLs from a browser-initiated request.

The problem here is that the web service URLs generated by a browser-initiated request look like "http://launchpad.dev/api/". Ordinarily this is fine, but xx-branchmergeproposal generates URLs from a browser-initiated request and then passes them into a web service client that expects URLs that look like "http://api.launchpad.dev/". Rather than try to come up with a standard way of doing this, I created a helper method in the test that does the translation.

This branch also upgrades the version of lazr.restful used. I'm not 100% sure that this new version of lazr.restful is necessary, and I'm going to do some preliminary tests with the old version before landing.

Incremental diff: http://pastebin.ubuntu.com/387107/

Revision history for this message
Leonard Richardson (leonardr) wrote :

I should mention that I'm still trying to track down a launchpadlib test failure.

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

r10428 and r10429 approved. I'd like fix_url to be removed eventually, but I'll not worry about it now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile'
--- Makefile 2010-02-19 22:02:36 +0000
+++ Makefile 2010-03-03 00:11:15 +0000
@@ -28,8 +28,10 @@
2828
29BZR_VERSION_INFO = bzr-version-info.py29BZR_VERSION_INFO = bzr-version-info.py
3030
31WADL_FILE = lib/canonical/launchpad/apidoc/wadl-$(LPCONFIG).xml31APIDOC_DIR = lib/canonical/launchpad/apidoc
32API_INDEX = lib/canonical/launchpad/apidoc/index.html32WADL_TEMPLATE = $(APIDOC_DIR).tmp/wadl-$(LPCONFIG)-%(version)s.xml
33DEVEL_WADL_FILE = $(APIDOC_DIR)/wadl-$(LPCONFIG)-devel.xml
34API_INDEX = $(APIDOC_DIR)/index.html
3335
34# DO NOT ALTER : this should just build by default36# DO NOT ALTER : this should just build by default
35default: inplace37default: inplace
@@ -44,12 +46,14 @@
44hosted_branches: $(PY)46hosted_branches: $(PY)
45 $(PY) ./utilities/make-dummy-hosted-branches47 $(PY) ./utilities/make-dummy-hosted-branches
4648
47$(WADL_FILE): $(BZR_VERSION_INFO)49$(DEVEL_WADL_FILE): $(BZR_VERSION_INFO)
48 LPCONFIG=$(LPCONFIG) $(PY) ./utilities/create-lp-wadl.py > $@.tmp50 mkdir $(APIDOC_DIR).tmp
49 mv $@.tmp $@51 LPCONFIG=$(LPCONFIG) $(PY) ./utilities/create-lp-wadl.py "$(WADL_TEMPLATE)"
52 mv $(APIDOC_DIR).tmp/* $(APIDOC_DIR)
53 rmdir $(APIDOC_DIR).tmp
5054
51$(API_INDEX): $(WADL_FILE)55$(API_INDEX): $(DEVEL_WADL_FILE)
52 bin/apiindex $(WADL_FILE) > $@.tmp56 bin/apiindex $(DEVEL_WADL_FILE) > $@.tmp
53 mv $@.tmp $@57 mv $@.tmp $@
5458
55apidoc: compile $(API_INDEX)59apidoc: compile $(API_INDEX)
@@ -240,7 +244,7 @@
240$(BZR_VERSION_INFO):244$(BZR_VERSION_INFO):
241 scripts/update-bzr-version-info.sh245 scripts/update-bzr-version-info.sh
242246
243support_files: $(WADL_FILE) $(BZR_VERSION_INFO)247support_files: $(DEVEL_WADL_FILE) $(BZR_VERSION_INFO)
244248
245# Intended for use on developer machines249# Intended for use on developer machines
246start: inplace stop support_files initscript-start250start: inplace stop support_files initscript-start
@@ -309,7 +313,11 @@
309 $(RM) -r lib/mailman313 $(RM) -r lib/mailman
310 $(RM) -rf lib/canonical/launchpad/icing/build/*314 $(RM) -rf lib/canonical/launchpad/icing/build/*
311 $(RM) -r $(CODEHOSTING_ROOT)315 $(RM) -r $(CODEHOSTING_ROOT)
312 $(RM) $(WADL_FILE) $(API_INDEX)316 mv $(APIDOC_DIR)/wadl-testrunner-devel.xml \
317 $(APIDOC_DIR)/wadl-testrunner-devel.xml.bak
318 $(RM) $(APIDOC_DIR)/wadl*.xml $(API_INDEX)
319 mv $(APIDOC_DIR)/wadl-testrunner-devel.xml.bak \
320 $(APIDOC_DIR)/wadl-testrunner-devel.xml
313 $(RM) $(BZR_VERSION_INFO)321 $(RM) $(BZR_VERSION_INFO)
314 $(RM) _pythonpath.py322 $(RM) _pythonpath.py
315 $(RM) -rf \323 $(RM) -rf \
316324
=== modified file 'configs/development/launchpad-lazr.conf'
--- configs/development/launchpad-lazr.conf 2010-02-24 05:00:02 +0000
+++ configs/development/launchpad-lazr.conf 2010-03-03 00:11:15 +0000
@@ -262,7 +262,7 @@
262262
263[vhost.api]263[vhost.api]
264hostname: api.launchpad.dev264hostname: api.launchpad.dev
265rooturl: https://api.launchpad.dev/beta/265rooturl: https://api.launchpad.dev/
266266
267[vhost.blueprints]267[vhost.blueprints]
268hostname: blueprints.launchpad.dev268hostname: blueprints.launchpad.dev
269269
=== modified file 'configs/testrunner-appserver/launchpad-lazr.conf'
--- configs/testrunner-appserver/launchpad-lazr.conf 2010-02-12 19:34:42 +0000
+++ configs/testrunner-appserver/launchpad-lazr.conf 2010-03-03 00:11:15 +0000
@@ -23,7 +23,7 @@
23rooturl: http://launchpad.dev:8085/23rooturl: http://launchpad.dev:8085/
2424
25[vhost.api]25[vhost.api]
26rooturl: http://api.launchpad.dev:8085/beta/26rooturl: http://api.launchpad.dev:8085/
2727
28[vhost.blueprints]28[vhost.blueprints]
29rooturl: http://blueprints.launchpad.dev:8085/29rooturl: http://blueprints.launchpad.dev:8085/
3030
=== modified file 'configs/testrunner/launchpad-lazr.conf'
--- configs/testrunner/launchpad-lazr.conf 2010-02-24 05:00:02 +0000
+++ configs/testrunner/launchpad-lazr.conf 2010-03-03 00:11:15 +0000
@@ -229,7 +229,7 @@
229rooturl: http://launchpad.dev/229rooturl: http://launchpad.dev/
230230
231[vhost.api]231[vhost.api]
232rooturl: http://api.launchpad.dev/beta/232rooturl: http://api.launchpad.dev/
233233
234[vhosts]234[vhosts]
235use_https: False235use_https: False
236236
=== renamed file 'lib/canonical/launchpad/apidoc/wadl-testrunner.xml' => 'lib/canonical/launchpad/apidoc/wadl-testrunner-devel.xml'
=== modified file 'lib/canonical/launchpad/doc/webapp-publication.txt'
--- lib/canonical/launchpad/doc/webapp-publication.txt 2010-02-12 19:34:42 +0000
+++ lib/canonical/launchpad/doc/webapp-publication.txt 2010-03-03 00:11:15 +0000
@@ -38,7 +38,7 @@
38 althosts:38 althosts:
39 ----39 ----
40 api @ api.launchpad.dev40 api @ api.launchpad.dev
41 rooturl: http://api.launchpad.dev/beta/41 rooturl: http://api.launchpad.dev/
42 althosts:42 althosts:
43 ----43 ----
44 blueprints @ blueprints.launchpad.dev44 blueprints @ blueprints.launchpad.dev
4545
=== modified file 'lib/canonical/launchpad/pagetests/webservice/xx-wadl.txt'
--- lib/canonical/launchpad/pagetests/webservice/xx-wadl.txt 2009-08-20 04:46:48 +0000
+++ lib/canonical/launchpad/pagetests/webservice/xx-wadl.txt 2010-03-03 00:11:15 +0000
@@ -1,16 +1,18 @@
1= Launchpad's WADL caching =1= Launchpad's WADL caching =
22
3Because Launchpad's main WADL file is so big, we cache it internally.3Because Launchpad's main WADL files are so big, we cache them
4Because it only changes when the Launchpad software changes, it is4internally: one WADL file for every version of the web service.
5cached to a file. Right now, the Launchpad webservice serves a5Because the WADL only changes when the Launchpad software changes,
6special test file (canonical/launchpad/apidoc/wadl-testrunner.xml)6these documents are cached to files. Right now, the Launchpad
7when a client asks for the big WADL definition. It was loaded on7webservice serves a special test file
8module import using the canonical.config.config.instance_name, so a8(canonical/launchpad/apidoc/wadl-testrunner-devel.xml) when a client
9development instance will use the file9asks for the big WADL definition for the 'devel' version. The
10canonical/launchpad/apidoc/wadl-development.xml.10'testrunner' part comes from canonical.config.config.instance_name, so
11a development instance will use the file
12canonical/launchpad/apidoc/wadl-development-{version}.xml.
1113
12 >>> test_wadl = webservice.get(14 >>> test_wadl = webservice.get(
13 ... '/', 'application/vd.sun.wadl+xml').body15 ... '/', 'application/vd.sun.wadl+xml', api_version='devel').body
14 >>> print test_wadl16 >>> print test_wadl
15 <?xml version="1.0"?>17 <?xml version="1.0"?>
16 <wadl:application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"18 <wadl:application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -24,15 +26,16 @@
24 </wadl:application>26 </wadl:application>
25 <BLANKLINE>27 <BLANKLINE>
2628
27Let's look at the real contents, though. To do this, we need to do29Let's look at the real contents, though. To do this, we need to
28what utilities/create-lp-wadl.py does: clear out the cache on the30deactivate the cache. Simply clearing it out will just cause it to be
29class.31filled up again.
3032
31 >>> from canonical.launchpad.systemhomes import WebServiceApplication33 >>> from canonical.launchpad.systemhomes import WebServiceApplication
34 >>> old_cached_wadl = WebServiceApplication.cached_wadl
32 >>> WebServiceApplication.cached_wadl = None35 >>> WebServiceApplication.cached_wadl = None
3336
34 >>> wadl = webservice.get(37 >>> wadl = webservice.get(
35 ... '/', 'application/vd.sun.wadl+xml').body38 ... '/', 'application/vd.sun.wadl+xml', api_version='devel').body
36 >>> wadl = wadl.decode('UTF-8')39 >>> wadl = wadl.decode('UTF-8')
3740
38The real file is much bigger than the test file.41The real file is much bigger than the test file.
@@ -40,15 +43,38 @@
40 >>> len(wadl) > len(test_wadl)43 >>> len(wadl) > len(test_wadl)
41 True44 True
4245
43The new output is now cached on the WebServiceApplication class.46The WADL we received is keyed to the 'devel' version of the web
4447service. This version will always be present.
45 >>> WebServiceApplication.cached_wadl == wadl48
49 >>> 'http://api.launchpad.dev/devel/' in wadl
50 True
51
52If we retrieve the WADL for the '1.0' version of the web service,
53we'll get a document keyed to the '1.0' version. The '1.0' version
54will be deprecated along with the Lucid release of Ubuntu.
55
56 >>> wadl_10 = webservice.get(
57 ... '/', 'application/vd.sun.wadl+xml', api_version='1.0').body
58 >>> wadl_10 = wadl_10.decode('UTF-8')
59
60 >>> 'http://api.launchpad.dev/1.0/' in wadl_10
61 True
62
63If we retrieve the WADL for the 'beta' version of the web service,
64we'll get a document keyed to the 'beta' version. The '1.0' version
65will be deprecated along with the Karmic release of Ubuntu.
66
67 >>> wadl_beta = webservice.get(
68 ... '/', 'application/vd.sun.wadl+xml', api_version='beta').body
69 >>> wadl_beta = wadl_beta.decode('UTF-8')
70
71 >>> 'http://api.launchpad.dev/beta/' in wadl_beta
46 True72 True
4773
48We don't need the cache anymore, so we'll reinstate the testing74We don't need the cache anymore, so we'll reinstate the testing
49version. This way, other tests will have a clean slate.75version. This way, other tests will have a clean slate.
5076
51 >>> WebServiceApplication.cached_wadl = test_wadl77 >>> WebServiceApplication.cached_wadl = old_cached_wadl
5278
53Like all lazr.restful applications, Launchpad's web service generates79Like all lazr.restful applications, Launchpad's web service generates
54valid WADL.80valid WADL.
5581
=== modified file 'lib/canonical/launchpad/systemhomes.py'
--- lib/canonical/launchpad/systemhomes.py 2010-02-16 14:07:17 +0000
+++ lib/canonical/launchpad/systemhomes.py 2010-03-03 00:11:15 +0000
@@ -343,15 +343,8 @@
343class WebServiceApplication(ServiceRootResource):343class WebServiceApplication(ServiceRootResource):
344 """See `IWebServiceApplication`.344 """See `IWebServiceApplication`.
345345
346 This implementation adds a 'cached_wadl' attribute. If set, it will be346 This implementation adds a 'cached_wadl' attribute, which starts
347 served by `toWADL` rather than calculating the toWADL result.347 out as an empty dict and is populated as needed.
348
349 On import, the class tries to load a file to populate this attribute. By
350 doing it on import, this makes it easy to clear, as is needed by
351 utilities/create-lp-wadl.py.
352
353 If the attribute is not set, toWADL will set the attribute on the class
354 once it is calculated.
355 """348 """
356 implements(IWebServiceApplication, ICanonicalUrlData)349 implements(IWebServiceApplication, ICanonicalUrlData)
357350
@@ -359,31 +352,41 @@
359 path = ''352 path = ''
360 rootsite = None353 rootsite = None
361354
362 _wadl_filename = os.path.join(355 cached_wadl = {}
363 os.path.dirname(os.path.normpath(__file__)),
364 'apidoc', 'wadl-%s.xml' % config.instance_name)
365
366 cached_wadl = None
367
368 # Attempt to load the WADL.
369 _wadl_fd = None
370 try:
371 _wadl_fd = codecs.open(_wadl_filename, encoding='UTF-8')
372 try:
373 cached_wadl = _wadl_fd.read()
374 finally:
375 _wadl_fd.close()
376 except IOError:
377 pass
378 del _wadl_fd
379356
380 def toWADL(self):357 def toWADL(self):
381 """See `IWebServiceApplication`."""358 """See `IWebServiceApplication`.
382 if self.cached_wadl is not None:359
383 return self.cached_wadl360 Look for a cached WADL file for the request version at the
384 wadl = super(WebServiceApplication, self).toWADL()361 location used by the script
385 self.__class__.cached_wadl = wadl362 utilities/create-launchpad-wadl.py. If the file is present,
386 return wadl363 load the file and cache its contents rather than generating
364 new WADL. Otherwise, generate new WADL and cache it.
365 """
366 version = self.request.version
367 if self.__class__.cached_wadl is None:
368 # The cache has been disabled for testing
369 # purposes. Generate the WADL.
370 return super(WebServiceApplication, self).toWADL()
371 if version not in self.__class__.cached_wadl:
372 # It's not cached. Look for it on disk.
373 _wadl_filename = os.path.join(
374 os.path.dirname(os.path.normpath(__file__)),
375 'apidoc', 'wadl-%s-%s.xml' % (config.instance_name, version))
376
377 _wadl_fd = None
378 try:
379 _wadl_fd = codecs.open(_wadl_filename, encoding='UTF-8')
380 try:
381 wadl = _wadl_fd.read()
382 finally:
383 _wadl_fd.close()
384 except IOError:
385 # It's not on disk; generate it.
386 wadl = super(WebServiceApplication, self).toWADL()
387 del _wadl_fd
388 self.__class__.cached_wadl[version] = wadl
389 return self.__class__.cached_wadl[version]
387390
388391
389class TestOpenIDApplication:392class TestOpenIDApplication:
390393
=== modified file 'lib/lp/code/stories/webservice/xx-branchmergeproposal.txt'
--- lib/lp/code/stories/webservice/xx-branchmergeproposal.txt 2010-02-26 09:54:20 +0000
+++ lib/lp/code/stories/webservice/xx-branchmergeproposal.txt 2010-03-03 00:11:15 +0000
@@ -7,13 +7,31 @@
7 >>> from lazr.restful.testing.webservice import pprint_entry7 >>> from lazr.restful.testing.webservice import pprint_entry
8 >>> login('admin@canonical.com')8 >>> login('admin@canonical.com')
9 >>> target = factory.makeBranch()9 >>> target = factory.makeBranch()
10 >>> target_url = str(canonical_url(target, rootsite='api'))10
11 >>> from canonical.launchpad.webapp.servers import WebServiceTestRequest
12 >>> request = WebServiceTestRequest(version="beta")
13 >>> request.processInputs()
14
15 >>> from lazr.restful.utils import get_current_web_service_request
16 >>> request = get_current_web_service_request()
17
18 >>> def fix_url(url):
19 ... """Convert a browser request to a web service client request.
20 ... This is a bit of a hack, but it's the simplest way to get a
21 ... URL that the web service client will respect."""
22 ... return url.replace("launchpad.dev/api/", "api.launchpad.dev/")
23
24 >>> target_url = fix_url(str(canonical_url(
25 ... target, request=request, rootsite='api')))
11 >>> source = factory.makeBranchTargetBranch(target.target)26 >>> source = factory.makeBranchTargetBranch(target.target)
12 >>> source_url = str(canonical_url(source, rootsite='api'))27 >>> source_url = fix_url(str(
28 ... canonical_url(source, request=request, rootsite='api')))
13 >>> prerequisite = factory.makeBranchTargetBranch(target.target)29 >>> prerequisite = factory.makeBranchTargetBranch(target.target)
14 >>> prerequisite_url = canonical_url(prerequisite, rootsite='api')30 >>> prerequisite_url = fix_url(str(canonical_url(
31 ... prerequisite, request=request, rootsite='api')))
15 >>> registrant = source.registrant32 >>> registrant = source.registrant
16 >>> reviewer_url = canonical_url(factory.makePerson(), rootsite='api')33 >>> reviewer_url = fix_url(str(canonical_url(
34 ... factory.makePerson(), request=request, rootsite='api')))
17 >>> logout()35 >>> logout()
18 >>> registrant_webservice = webservice_for_person(36 >>> registrant_webservice = webservice_for_person(
19 ... registrant, permission=OAuthPermission.WRITE_PUBLIC)37 ... registrant, permission=OAuthPermission.WRITE_PUBLIC)
@@ -28,7 +46,7 @@
28 >>> pprint_entry(bmp)46 >>> pprint_entry(bmp)
29 address: u'mp+...@code.launchpad.dev'47 address: u'mp+...@code.launchpad.dev'
30 all_comments_collection_link:48 all_comments_collection_link:
31 u'http://api.launchpad.dev/beta/~.../+merge/.../all_comments'49 u'http://api.launchpad.dev/devel/~.../+merge/.../all_comments'
32 commit_message: u'It was merged!\n'50 commit_message: u'It was merged!\n'
33 date_created: u'...'51 date_created: u'...'
34 date_merged: None52 date_merged: None
@@ -38,40 +56,40 @@
38 description: u'Merge\nit!'56 description: u'Merge\nit!'
39 merge_reporter_link: None57 merge_reporter_link: None
40 merged_revno: None58 merged_revno: None
41 prerequisite_branch_link: u'http://api.launchpad.dev/beta/~...'59 prerequisite_branch_link: u'http://api.launchpad.dev/devel/~...'
42 preview_diff_link: None60 preview_diff_link: None
43 private: False61 private: False
44 queue_position: None62 queue_position: None
45 queue_status: u'Needs review'63 queue_status: u'Needs review'
46 queued_revid: None64 queued_revid: None
47 queuer_link: None65 queuer_link: None
48 registrant_link: u'http://api.launchpad.dev/beta/~person-name...'66 registrant_link: u'http://api.launchpad.dev/devel/~person-name...'
49 resource_type_link:67 resource_type_link:
50 u'http://api.launchpad.dev/beta/#branch_merge_proposal'68 u'http://api.launchpad.dev/devel/#branch_merge_proposal'
51 reviewed_revid: None69 reviewed_revid: None
52 reviewer_link: None70 reviewer_link: None
53 self_link: u'http://api.launchpad.dev/beta/~.../+merge/...'71 self_link: u'http://api.launchpad.dev/devel/~.../+merge/...'
54 source_branch_link: u'http://api.launchpad.dev/beta/~...'72 source_branch_link: u'http://api.launchpad.dev/devel/~...'
55 superseded_by_link: None73 superseded_by_link: None
56 supersedes_link: None74 supersedes_link: None
57 target_branch_link: u'http://api.launchpad.dev/beta/~...'75 target_branch_link: u'http://api.launchpad.dev/devel/~...'
58 votes_collection_link:76 votes_collection_link:
59 u'http://api.launchpad.dev/beta/~.../+merge/.../votes'77 u'http://api.launchpad.dev/devel/~.../+merge/.../votes'
6078
61Our review request is listed in the votes collection.79Our review request is listed in the votes collection.
6280
63 >>> votes = webservice.get(81 >>> votes = webservice.get(
64 ... bmp['votes_collection_link']).jsonBody()82 ... bmp['votes_collection_link']).jsonBody()
65 >>> pprint_entry(votes['entries'][0])83 >>> pprint_entry(votes['entries'][0])
66 branch_merge_proposal_link: u'http://api.launchpad.dev/beta/~.../+merge/...'84 branch_merge_proposal_link: u'http://api.launchpad.dev/devel/~.../+merge/...'
67 comment_link: None85 comment_link: None
68 date_created: u'...'86 date_created: u'...'
69 is_pending: True87 is_pending: True
70 registrant_link: u'http://api.launchpad.dev/beta/~person-name...'88 registrant_link: u'http://api.launchpad.dev/devel/~person-name...'
71 resource_type_link: u'http://api.launchpad.dev/beta/#code_review_vote_reference'89 resource_type_link: u'http://api.launchpad.dev/devel/#code_review_vote_reference'
72 review_type: u'green'90 review_type: u'green'
73 reviewer_link: u'http://api.launchpad.dev/beta/~person-name...'91 reviewer_link: u'http://api.launchpad.dev/devel/~person-name...'
74 self_link: u'http://api.launchpad.dev/beta/~...'92 self_link: u'http://api.launchpad.dev/devel/~...'
7593
7694
77== Get an existing merge proposal ==95== Get an existing merge proposal ==
@@ -96,7 +114,8 @@
96 ... vote=CodeReviewVote.ABSTAIN, parent=comment,114 ... vote=CodeReviewVote.ABSTAIN, parent=comment,
97 ... merge_proposal=fixit_proposal)115 ... merge_proposal=fixit_proposal)
98116
99 >>> proposal_url = canonical_url(fixit_proposal, rootsite='api')117 >>> proposal_url = fix_url(canonical_url(
118 ... fixit_proposal, request=request, rootsite='api'))
100 >>> new_person = factory.makePerson()119 >>> new_person = factory.makePerson()
101 >>> target_owner = fixit_proposal.target_branch.owner120 >>> target_owner = fixit_proposal.target_branch.owner
102 >>> logout()121 >>> logout()
103122
=== modified file 'utilities/create-lp-wadl.py'
--- utilities/create-lp-wadl.py 2009-10-17 14:06:03 +0000
+++ utilities/create-lp-wadl.py 2010-03-03 00:11:15 +0000
@@ -7,12 +7,15 @@
77
8Usage hint:8Usage hint:
99
10% LPCONFIG="edge" utilities/create-lp-wadl.py > launchpad.wadl10% LPCONFIG="edge" utilities/create-lp-wadl.py launchpad-%(version)s.wadl
11"""11"""
1212
13import _pythonpath13import _pythonpath
1414
15import sys15import sys
16import urlparse
17
18from zope.component import getUtility
1619
17from canonical.launchpad.ftests import login, ANONYMOUS20from canonical.launchpad.ftests import login, ANONYMOUS
18from canonical.launchpad.scripts import execute_zcml_for_scripts21from canonical.launchpad.scripts import execute_zcml_for_scripts
@@ -20,27 +23,41 @@
20 WebServicePublication, WebServiceTestRequest)23 WebServicePublication, WebServiceTestRequest)
21from canonical.launchpad.webapp.vhosts import allvhosts24from canonical.launchpad.webapp.vhosts import allvhosts
22from canonical.launchpad.systemhomes import WebServiceApplication25from canonical.launchpad.systemhomes import WebServiceApplication
26from lazr.restful.interfaces import IWebServiceConfiguration
2327
24def main():28def main(path_template):
25 WebServiceApplication.cached_wadl = None # do not use cached file version29 WebServiceApplication.cached_wadl = None # do not use cached file version
26 execute_zcml_for_scripts()30 execute_zcml_for_scripts()
31 config = getUtility(IWebServiceConfiguration)
2732
28 # Request the WADL from the root resource.33 # Request the WADL from the root resource.
29 # We do this by creating a request object asking for a WADL34 # We do this by creating a request object asking for a WADL
30 # representation.35 # representation.
31 request = WebServiceTestRequest(environ={36 for version in config.active_versions:
32 'SERVER_URL': allvhosts.configs['api'].rooturl,37 url = urlparse.urljoin(allvhosts.configs['api'].rooturl, version)
33 'HTTP_HOST': allvhosts.configs['api'].hostname,38 request = WebServiceTestRequest(version=version, environ={
34 'HTTP_ACCEPT': 'application/vd.sun.wadl+xml'39 'SERVER_URL': url,
35 })40 'HTTP_HOST': allvhosts.configs['api'].hostname,
36 # We then bypass the usual publisher processing by associating41 'HTTP_ACCEPT': 'application/vd.sun.wadl+xml'
37 # the request with the WebServicePublication (usually done by the42 })
38 # publisher) and then calling the root resource - retrieved through43 # We then bypass the usual publisher processing by associating
39 # getApplication().44 # the request with the WebServicePublication (usually done by the
40 request.setPublication(WebServicePublication(None))45 # publisher) and then calling the root resource - retrieved through
41 login(ANONYMOUS, request)46 # getApplication().
42 print request.publication.getApplication(request)(request)47 request.setPublication(WebServicePublication(None))
48 login(ANONYMOUS, request)
49 filename = path_template % {'version' : version}
50 print "Writing WADL for version %s to %s." % (version, filename)
51 f = open(filename, 'w')
52 content = request.publication.getApplication(request)(request)
53 f.write(content)
54 f.close()
43 return 055 return 0
4456
45if __name__ == '__main__':57if __name__ == '__main__':
46 sys.exit(main())58 if len(sys.argv) != 2:
59 print "Usage: %s [WADL path template]" % sys.argv[0]
60 print " Example: %s path/to/wadl/wadl-%%(version).xml" % (
61 sys.argv[0])
62 sys.exit(-1)
63 sys.exit(main(sys.argv[1]))

Subscribers

People subscribed via source and target branches

to status/vote changes: