Merge lp:~leonardr/lazr.restful/move-example into lp:lazr.restful

Proposed by Leonard Richardson
Status: Merged
Approved by: Graham Binns
Approved revision: 68
Merged at revision: not available
Proposed branch: lp:~leonardr/lazr.restful/move-example
Merge into: lp:lazr.restful
Diff against target: None lines
To merge this branch: bzr merge lp:~leonardr/lazr.restful/move-example
Reviewer Review Type Date Requested Status
Graham Binns (community) Approve
Review via email: mp+10974@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) wrote :

In the beginning there was one lazr.restful example web service, and it lived in lazr.restful.example. Then I created the WSGI example web service, in lazr.restful.example.wsgi. The problem with this packaging arrangement is it makes the WSGI web service look like part of the basic example service. Actually, they're two completely different services.

I was planning to fix this eventually, and now I have to fix it, because I'm trying to introduce grok into the mix. When you grok a package, it recursively groks all sub-packages. That means that the WSGI service's configuration is interfering with the basic service's configuration. The solution is to move the basic service into lazr.restful.example.base, making it totally separate from lazr.restful.example.wsgi.

All I've done in this branch is move the files and change the external references.

Revision history for this message
Graham Binns (gmb) :
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/README.txt'
2--- src/lazr/restful/README.txt 2009-08-04 14:17:40 +0000
3+++ src/lazr/restful/README.txt 2009-09-01 12:24:18 +0000
4@@ -35,11 +35,11 @@
5 ============================
6
7 To understand all of lazr.restful, you should look at the web service
8-defined in src/lazr/restful/example/. It defines a simple application
9-serving information about cookbooks and recipes. The interfaces
10-(interfaces.py) are annotated with lazr.restful decorators that say
11-which fields and methods to publish from IRecipe, ICookbook, and so
12-on. The implementations of those interfaces are in root.py.
13+defined in src/lazr/restful/example/base/. It defines a simple
14+application serving information about cookbooks and recipes. The
15+interfaces (interfaces.py) are annotated with lazr.restful decorators
16+that say which fields and methods to publish from IRecipe, ICookbook,
17+and so on. The implementations of those interfaces are in root.py.
18
19 The machinery of lazr.restful takes the decorators in interfaces.py,
20 and generates an interface that maps incoming HTTP requests to
21@@ -48,7 +48,7 @@
22 you do have to know a fair amount about Zope).
23
24 You can test the example web service by running `bin/test`. The
25-doctests in src/lazr/restful/example/tests use a fake httplib2
26+doctests in src/lazr/restful/example/base/tests use a fake httplib2
27 connection to simulate HTTP requests to the web service. You can watch
28 the tests make GET, PUT, POST, PATCH, and DELETE requests to the web
29 service. Start with root.txt.
30
31=== modified file 'src/lazr/restful/docs/webservice-marshallers.txt'
32--- src/lazr/restful/docs/webservice-marshallers.txt 2009-08-11 18:36:20 +0000
33+++ src/lazr/restful/docs/webservice-marshallers.txt 2009-09-01 12:07:59 +0000
34@@ -10,7 +10,7 @@
35
36 >>> from lazr.restful.testing.webservice import WebServiceTestPublication
37 >>> from lazr.restful.simple import Request
38- >>> from lazr.restful.example.root import (
39+ >>> from lazr.restful.example.base.root import (
40 ... CookbookServiceRootResource)
41 >>> request = Request("", {'HTTP_HOST': 'cookbooks.dev'})
42 >>> application = CookbookServiceRootResource()
43@@ -469,7 +469,7 @@
44 And the unmarshall() method returns a link that will serve the file.
45
46 >>> from lazr.restful import EntryResource
47- >>> from lazr.restful.example.interfaces import ICookbookSet
48+ >>> from lazr.restful.example.base.interfaces import ICookbookSet
49 >>> from zope.component import getUtility
50 >>> entry_resource = EntryResource(
51 ... getUtility(ICookbookSet).get('Everyday Greens'), request)
52@@ -604,7 +604,7 @@
53 value. A string that doesn't correspond to any enumerated value results
54 in a helpful ValueError.
55
56- >>> from lazr.restful.example.interfaces import Cuisine
57+ >>> from lazr.restful.example.base.interfaces import Cuisine
58 >>> field = Choice(vocabulary=Cuisine)
59 >>> marshaller = getMultiAdapter((field, request), IFieldMarshaller)
60 >>> verifyObject(IFieldMarshaller, marshaller)
61@@ -648,14 +648,14 @@
62 An object is marshalled to its URL.
63
64 >>> from lazr.restful.fields import Reference
65- >>> from lazr.restful.example.interfaces import ICookbook
66+ >>> from lazr.restful.example.base.interfaces import ICookbook
67 >>> reference_field = Reference(schema=ICookbook)
68 >>> reference_marshaller = getMultiAdapter(
69 ... (reference_field, request), IFieldMarshaller)
70 >>> verifyObject(IFieldMarshaller, reference_marshaller)
71 True
72
73- >>> from lazr.restful.example.root import COOKBOOKS
74+ >>> from lazr.restful.example.base.root import COOKBOOKS
75 >>> cookbook = COOKBOOKS[0]
76 >>> cookbook_url = reference_marshaller.unmarshall(None, cookbook)
77 >>> print cookbook_url
78@@ -679,7 +679,7 @@
79
80 >>> from zope.schema import List, Tuple, Set
81 >>> list_of_strings_field = List(value_type=Text())
82- >>> from lazr.restful.example.interfaces import Cuisine
83+ >>> from lazr.restful.example.base.interfaces import Cuisine
84 >>> tuple_of_ints_field = Tuple(value_type=Int())
85 >>> list_of_choices_field = List(
86 ... value_type=Choice(vocabulary=Cuisine))
87@@ -799,7 +799,7 @@
88 something like that.)
89
90 >>> from lazr.restful.fields import CollectionField
91- >>> from lazr.restful.example.interfaces import IRecipe
92+ >>> from lazr.restful.example.base.interfaces import IRecipe
93 >>> field = CollectionField(
94 ... __name__='recipes', value_type=Reference(schema=IRecipe))
95 >>> marshaller = getMultiAdapter((field, request), IFieldMarshaller)
96
97=== modified file 'src/lazr/restful/docs/webservice.txt'
98--- src/lazr/restful/docs/webservice.txt 2009-08-27 15:50:55 +0000
99+++ src/lazr/restful/docs/webservice.txt 2009-09-01 12:07:59 +0000
100@@ -503,7 +503,7 @@
101 ... <configure xmlns="http://namespaces.zope.org/zope">
102 ... <include package="lazr.restful" file="basic-site.zcml"/>
103 ... <utility
104- ... factory="lazr.restful.example.filemanager.FileManager" />
105+ ... factory="lazr.restful.example.base.filemanager.FileManager" />
106 ... </configure>
107 ... """)
108
109@@ -1701,9 +1701,9 @@
110 implementation that serves all files from the /files path.
111
112 >>> from lazr.restful.interfaces import IByteStorage
113- >>> from lazr.restful.example.interfaces import (
114+ >>> from lazr.restful.example.base.interfaces import (
115 ... IFileManagerBackedByteStorage)
116- >>> from lazr.restful.example.root import SimpleByteStorage
117+ >>> from lazr.restful.example.base.root import SimpleByteStorage
118 >>> protect_schema(SimpleByteStorage, IFileManagerBackedByteStorage)
119 >>> sm.registerAdapter(SimpleByteStorage, provided=IByteStorage)
120
121
122=== added directory 'src/lazr/restful/example/base'
123=== added file 'src/lazr/restful/example/base/__init__.py'
124=== renamed file 'src/lazr/restful/example/configure.zcml' => 'src/lazr/restful/example/base/configure.zcml'
125--- src/lazr/restful/example/configure.zcml 2009-08-27 15:50:55 +0000
126+++ src/lazr/restful/example/base/configure.zcml 2009-09-01 12:07:59 +0000
127@@ -2,17 +2,17 @@
128 xmlns="http://namespaces.zope.org/zope"
129 xmlns:webservice="http://namespaces.canonical.com/webservice">
130
131- <webservice:register module="lazr.restful.example.interfaces" />
132+ <webservice:register module="lazr.restful.example.base.interfaces" />
133
134- <class class="lazr.restful.example.root.CookbookSet">
135- <allow interface='lazr.restful.example.interfaces.ICookbookSet' />
136+ <class class="lazr.restful.example.base.root.CookbookSet">
137+ <allow interface='lazr.restful.example.base.interfaces.ICookbookSet' />
138 </class>
139
140- <permission id="lazr.restful.example.View" title="Viewing something" />
141- <permission id="lazr.restful.example.ViewPrivate"
142+ <permission id="lazr.restful.example.base.View" title="Viewing something" />
143+ <permission id="lazr.restful.example.base.ViewPrivate"
144 title="Viewing private information" />
145
146- <class class="lazr.restful.example.root.Cookbook">
147+ <class class="lazr.restful.example.base.root.Cookbook">
148 <require attributes="name copyright_date cover cuisine description
149 recipes find_recipe_for find_recipes last_printing
150 make_more_interesting price replace_cover
151@@ -22,77 +22,77 @@
152 permission="zope.Public" />
153 <require attributes="confirmed"
154 set_attributes="confirmed"
155- permission="lazr.restful.example.ViewPrivate" />
156+ permission="lazr.restful.example.base.ViewPrivate" />
157 </class>
158
159- <class class="lazr.restful.example.root.Dish">
160- <require interface='lazr.restful.example.interfaces.IDish'
161- set_schema='lazr.restful.example.interfaces.IDish'
162+ <class class="lazr.restful.example.base.root.Dish">
163+ <require interface='lazr.restful.example.base.interfaces.IDish'
164+ set_schema='lazr.restful.example.base.interfaces.IDish'
165 permission = "zope.Public" />
166 </class>
167
168- <class class="lazr.restful.example.root.DishSet">
169- <allow interface='lazr.restful.example.interfaces.IDishSet' />
170- </class>
171-
172- <class class="lazr.restful.example.root.Recipe">
173- <require interface='lazr.restful.example.interfaces.IRecipe'
174- set_schema='lazr.restful.example.interfaces.IRecipe'
175- permission="lazr.restful.example.ViewPrivate" />
176- </class>
177-
178- <class class="lazr.restful.example.root.RecipeSet">
179- <allow interface='lazr.restful.example.interfaces.IRecipeSet' />
180+ <class class="lazr.restful.example.base.root.DishSet">
181+ <allow interface='lazr.restful.example.base.interfaces.IDishSet' />
182+ </class>
183+
184+ <class class="lazr.restful.example.base.root.Recipe">
185+ <require interface='lazr.restful.example.base.interfaces.IRecipe'
186+ set_schema='lazr.restful.example.base.interfaces.IRecipe'
187+ permission="lazr.restful.example.base.ViewPrivate" />
188+ </class>
189+
190+ <class class="lazr.restful.example.base.root.RecipeSet">
191+ <allow interface='lazr.restful.example.base.interfaces.IRecipeSet' />
192 </class>
193
194 <utility
195- factory="lazr.restful.example.root.WebServiceConfiguration" />
196-
197- <utility factory="lazr.restful.example.filemanager.FileManager" />
198-
199- <class class="lazr.restful.example.filemanager.FileManager">
200- <allow interface='lazr.restful.example.interfaces.IFileManager' />
201+ factory="lazr.restful.example.base.root.WebServiceConfiguration" />
202+
203+ <utility factory="lazr.restful.example.base.filemanager.FileManager" />
204+
205+ <class class="lazr.restful.example.base.filemanager.FileManager">
206+ <allow interface='lazr.restful.example.base.interfaces.IFileManager' />
207 </class>
208
209- <class class="lazr.restful.example.filemanager.ManagedFileResource">
210+ <class class="lazr.restful.example.base.filemanager.ManagedFileResource">
211 <allow interface='lazr.restful.interfaces.IHTTPResource' />
212 </class>
213
214- <utility factory="lazr.restful.example.root.CookbookSet"
215- provides="lazr.restful.example.interfaces.ICookbookSet"/>
216- <utility factory="lazr.restful.example.root.DishSet"
217- provides="lazr.restful.example.interfaces.IDishSet"/>
218- <utility factory="lazr.restful.example.root.RecipeSet"
219- provides="lazr.restful.example.interfaces.IRecipeSet"/>
220+ <utility factory="lazr.restful.example.base.root.CookbookSet"
221+ provides="lazr.restful.example.base.interfaces.ICookbookSet"/>
222+ <utility factory="lazr.restful.example.base.root.DishSet"
223+ provides="lazr.restful.example.base.interfaces.IDishSet"/>
224+ <utility factory="lazr.restful.example.base.root.RecipeSet"
225+ provides="lazr.restful.example.base.interfaces.IRecipeSet"/>
226
227 <utility
228- factory="lazr.restful.example.root.FeaturedCookbookLink"
229- provides="lazr.restful.example.interfaces.IFeaturedCookbookLink" />
230+ factory="lazr.restful.example.base.root.FeaturedCookbookLink"
231+ provides="lazr.restful.example.base.interfaces.IFeaturedCookbookLink" />
232
233 <utility
234 provides="lazr.restful.interfaces.IServiceRootResource"
235- factory="lazr.restful.example.root.CookbookServiceRootResource" />
236+ factory="lazr.restful.example.base.root.CookbookServiceRootResource" />
237
238- <adapter factory="lazr.restful.example.root.SimpleByteStorage"
239+ <adapter factory="lazr.restful.example.base.root.SimpleByteStorage"
240 provides="lazr.restful.interfaces.IByteStorage"/>
241- <class class="lazr.restful.example.root.SimpleByteStorage">
242- <allow interface='lazr.restful.example.interfaces.IFileManagerBackedByteStorage' />
243+ <class class="lazr.restful.example.base.root.SimpleByteStorage">
244+ <allow interface='lazr.restful.example.base.interfaces.IFileManagerBackedByteStorage' />
245 </class>
246
247
248- <adapter factory="lazr.restful.example.traversal.TraverseWithGet" />
249+ <adapter factory="lazr.restful.example.base.traversal.TraverseWithGet" />
250 <adapter
251- factory="lazr.restful.example.traversal.CookbookSetTraverse" />
252+ factory="lazr.restful.example.base.traversal.CookbookSetTraverse" />
253
254 <adapter
255- for="lazr.restful.example.root.CookbookWebServiceObject
256+ for="lazr.restful.example.base.root.CookbookWebServiceObject
257 lazr.restful.interfaces.IWebServiceLayer"
258 provides="zope.traversing.browser.interfaces.IAbsoluteURL"
259 factory="zope.traversing.browser.absoluteurl.AbsoluteURL"
260 />
261
262 <adapter
263- for="lazr.restful.example.root.CookbookWebServiceObject
264+ for="lazr.restful.example.base.root.CookbookWebServiceObject
265 lazr.restful.interfaces.IWebServiceLayer"
266 provides="zope.traversing.browser.interfaces.IAbsoluteURL"
267 factory="zope.traversing.browser.absoluteurl.AbsoluteURL"
268@@ -102,9 +102,9 @@
269 <adapter factory="lazr.restful.simple.RootResourceAbsoluteURL" />
270
271 <subscriber
272- for="lazr.restful.example.interfaces.ICookbook
273+ for="lazr.restful.example.base.interfaces.ICookbook
274 lazr.lifecycle.interfaces.IObjectModifiedEvent"
275- handler="lazr.restful.example.subscribers.update_cookbook_revision_number" />
276+ handler="lazr.restful.example.base.subscribers.update_cookbook_revision_number" />
277
278
279 </configure>
280
281=== renamed file 'src/lazr/restful/example/filemanager.py' => 'src/lazr/restful/example/base/filemanager.py'
282--- src/lazr/restful/example/filemanager.py 2009-04-17 14:40:17 +0000
283+++ src/lazr/restful/example/base/filemanager.py 2009-09-01 12:07:59 +0000
284@@ -12,7 +12,7 @@
285 from zope.interface import implements
286
287 from lazr.restful import ReadOnlyResource
288-from lazr.restful.example.interfaces import IFileManager
289+from lazr.restful.example.base.interfaces import IFileManager
290 from lazr.restful.utils import get_current_browser_request
291
292
293
294=== renamed file 'src/lazr/restful/example/interfaces.py' => 'src/lazr/restful/example/base/interfaces.py'
295=== renamed file 'src/lazr/restful/example/root.py' => 'src/lazr/restful/example/base/root.py'
296--- src/lazr/restful/example/root.py 2009-08-27 15:50:55 +0000
297+++ src/lazr/restful/example/base/root.py 2009-09-01 12:07:59 +0000
298@@ -22,7 +22,7 @@
299 from lazr.restful.interfaces import (
300 IByteStorage, IEntry, IServiceRootResource, ITopLevelEntryLink,
301 IWebServiceConfiguration)
302-from lazr.restful.example.interfaces import (
303+from lazr.restful.example.base.interfaces import (
304 AlreadyNew, Cuisine, ICookbook, ICookbookSet, IDish, IDishSet,
305 IFileManager, IRecipe, IRecipeSet, IHasGet, NameAlreadyTaken)
306 from lazr.restful.simple import make_simple_configuration
307@@ -369,7 +369,7 @@
308 match_batch_size=50,
309 service_version_uri_prefix='1.0',
310 use_https=False,
311- view_permission='lazr.restful.example.View',
312+ view_permission='lazr.restful.example.base.View',
313 )
314
315 WebServiceConfiguration = make_simple_configuration(
316
317=== renamed file 'src/lazr/restful/example/security.py' => 'src/lazr/restful/example/base/security.py'
318--- src/lazr/restful/example/security.py 2009-03-26 17:25:22 +0000
319+++ src/lazr/restful/example/base/security.py 2009-09-01 12:07:59 +0000
320@@ -9,7 +9,7 @@
321
322 from zope.security.simplepolicies import PermissiveSecurityPolicy
323 from zope.security.proxy import removeSecurityProxy
324-from lazr.restful.example.interfaces import ICookbook, IRecipe
325+from lazr.restful.example.base.interfaces import ICookbook, IRecipe
326
327
328 class CookbookWebServiceSecurityPolicy(PermissiveSecurityPolicy):
329@@ -19,12 +19,12 @@
330 """Check against a simple policy.
331
332 * Private recipes are always hidden.
333- * Any fields protected by lazr.restful.example.ViewPrivate are
334+ * Any fields protected by lazr.restful.example.base.ViewPrivate are
335 hidden.
336 """
337 if IRecipe.providedBy(object):
338 return not removeSecurityProxy(object).private
339- elif permission == "lazr.restful.example.ViewPrivate":
340+ elif permission == "lazr.restful.example.base.ViewPrivate":
341 return False
342 else:
343 return True
344
345=== renamed file 'src/lazr/restful/example/subscribers.py' => 'src/lazr/restful/example/base/subscribers.py'
346--- src/lazr/restful/example/subscribers.py 2009-04-24 15:14:07 +0000
347+++ src/lazr/restful/example/base/subscribers.py 2009-09-01 12:07:59 +0000
348@@ -5,7 +5,7 @@
349 __metaclass__ = type
350 __all__ = ['update_cookbook_revision_number']
351
352-from lazr.restful.example.interfaces import ICookbook
353+from lazr.restful.example.base.interfaces import ICookbook
354
355 def update_cookbook_revision_number(object, event):
356 """Increment ICookbook.revision_number."""
357
358=== renamed directory 'src/lazr/restful/example/tests' => 'src/lazr/restful/example/base/tests'
359=== renamed file 'src/lazr/restful/example/traversal.py' => 'src/lazr/restful/example/base/traversal.py'
360--- src/lazr/restful/example/traversal.py 2009-03-27 04:25:34 +0000
361+++ src/lazr/restful/example/base/traversal.py 2009-09-01 12:07:59 +0000
362@@ -14,7 +14,7 @@
363 from zope.publisher.interfaces.browser import IDefaultBrowserLayer
364 from zope.traversing.browser import absoluteURL
365
366-from lazr.restful.example.interfaces import ICookbookSet, IHasGet
367+from lazr.restful.example.base.interfaces import ICookbookSet, IHasGet
368 from lazr.restful import RedirectResource
369
370
371
372=== modified file 'src/lazr/restful/ftesting.zcml'
373--- src/lazr/restful/ftesting.zcml 2009-08-04 19:27:13 +0000
374+++ src/lazr/restful/ftesting.zcml 2009-09-01 12:07:59 +0000
375@@ -4,9 +4,9 @@
376 i18n_domain="lazr">
377
378 <include package="lazr.restful" file="basic-site.zcml"/>
379- <include package="lazr.restful.example" file="configure.zcml" />
380+ <include package="lazr.restful.example.base" file="configure.zcml" />
381 <securityPolicy
382- component="lazr.restful.example.security.CookbookWebServiceSecurityPolicy"
383+ component="lazr.restful.example.base.security.CookbookWebServiceSecurityPolicy"
384 />
385
386 </configure>

Subscribers

People subscribed via source and target branches