This is good to go once you fix the conflit marker and handle my few other
comments.
Cheers
> === modified file 'src/lazr/restful/docs/multiversion.txt'
> --- src/lazr/restful/docs/multiversion.txt 2009-11-19 16:43:08 +0000
> +++ src/lazr/restful/docs/multiversion.txt 2010-01-06 17:40:25 +0000
> @@ -5,10 +5,99 @@
> services. Typically these different services represent successive
> versions of a single web service, improved over time.
>
> +Setup
> +=====
> +
> +First, let's set up the web service infrastructure. Doing this first
> +will let us create HTTP requests for different versions of the web
> +service. The first step is to make all component lookups use the
> +global site manager.
> +
> + >>> from zope.component import getSiteManager
> + >>> sm = getSiteManager()
> +
> + >>> from zope.component import adapter
> + >>> from zope.component.interfaces import IComponentLookup
> + >>> from zope.interface import implementer, Interface
> + >>> @implementer(IComponentLookup)
> + ... @adapter(Interface)
> + ... def everything_uses_the_global_site_manager(context):
> + ... return sm
> + >>> sm.registerAdapter(everything_uses_the_global_site_manager)
Like discussed on IRC, the waving of this dead chicken isn't needed :-)
> +
> +Defining the request interfaces
> +-------------------------------
> +
> +Every version must have a corresponding subclass of
> +IWebServiceClientRequest. These marker interfaces let lazr.restful
> +keep track of which version of the web service a particular client
> +wants to use. In a real application, these interfaces will be
> +generated and registered automatically.
> +
> + >>> from lazr.restful.interfaces import (
> + ... IVersionedClientRequestImplementation, IWebServiceClientRequest)
> + >>> class IWebServiceRequestBeta(IWebServiceClientRequest):
> + ... pass
> +
> + >>> class IWebServiceRequest10(IWebServiceClientRequest):
> + ... pass
> +
> + >>> class IWebServiceRequestDev(IWebServiceClientRequest):
> + ... pass
> +
> + >>> request_classes = [IWebServiceRequestBeta,
> + ... IWebServiceRequest10, IWebServiceRequestDev]
> +
> + >>> from zope.interface import alsoProvides
> + >>> for cls, version in ((IWebServiceRequestBeta, 'beta'),
> + ... (IWebServiceRequest10, '1.0'),
> + ... (IWebServiceRequestDev, 'dev')):
> + ... alsoProvides(cls, IVersionedClientRequestImplementation)
> + ... sm.registerUtility(cls, IVersionedClientRequestImplementation,
> + ... name=version)
> +
Can you explain the use of IVersionedClientRequestImplementation? You
explained on IRC that it to make it easy to retrieve the interface related to
a version string.
Would IVersionedWebClientRequestFactory be a better name?
> +<<<<<<< TREE
> >>> for version in ['beta', 'dev', '1.0']:
> ... sm.registerAdapter(
> ... ContactCollection, provided=ICollection, name=version)
> @@ -397,3 +495,105 @@
> >>> print absoluteURL(dev_app, dev_request)
> http://api.multiversion.dev/dev/
>
> +=======
> class IWebServiceClientRequest(IBrowserRequest):
> - """Marker interface requests to the web service."""
> + """Interface for requests to the web service."""
> + version = Attribute("The version of the web service that the client "
> + "requested.")
Does this branch introduce that attribute? If it does, where is the doctest
example showing it's use?
Hi Leonard,
Nice to see this coming along.
This is good to go once you fix the conflit marker and handle my few other
comments.
Cheers
> === modified file 'src/lazr/ restful/ docs/multiversi on.txt' restful/ docs/multiversi on.txt 2009-11-19 16:43:08 +0000 restful/ docs/multiversi on.txt 2010-01-06 17:40:25 +0000 interfaces import IComponentLookup IComponentLooku p) uses_the_ global_ site_manager( context) : ter(everything_ uses_the_ global_ site_manager)
> --- src/lazr/
> +++ src/lazr/
> @@ -5,10 +5,99 @@
> services. Typically these different services represent successive
> versions of a single web service, improved over time.
>
> +Setup
> +=====
> +
> +First, let's set up the web service infrastructure. Doing this first
> +will let us create HTTP requests for different versions of the web
> +service. The first step is to make all component lookups use the
> +global site manager.
> +
> + >>> from zope.component import getSiteManager
> + >>> sm = getSiteManager()
> +
> + >>> from zope.component import adapter
> + >>> from zope.component.
> + >>> from zope.interface import implementer, Interface
> + >>> @implementer(
> + ... @adapter(Interface)
> + ... def everything_
> + ... return sm
> + >>> sm.registerAdap
Like discussed on IRC, the waving of this dead chicken isn't needed :-)
> + ------- ------- ------- ---- entRequest. These marker interfaces let lazr.restful interfaces import ( tRequestImpleme ntation, IWebServiceClie ntRequest) estBeta( IWebServiceClie ntRequest) : est10(IWebServi ceClientRequest ): estDev( IWebServiceClie ntRequest) : uestBeta, est10, IWebServiceRequ estDev] questBeta, 'beta'), uest10, '1.0'), uestDev, 'dev')): tRequestImpleme ntation) ity(cls, IVersionedClien tRequestImpleme ntation,
> +Defining the request interfaces
> +------
> +
> +Every version must have a corresponding subclass of
> +IWebServiceCli
> +keep track of which version of the web service a particular client
> +wants to use. In a real application, these interfaces will be
> +generated and registered automatically.
> +
> + >>> from lazr.restful.
> + ... IVersionedClien
> + >>> class IWebServiceRequ
> + ... pass
> +
> + >>> class IWebServiceRequ
> + ... pass
> +
> + >>> class IWebServiceRequ
> + ... pass
> +
> + >>> request_classes = [IWebServiceReq
> + ... IWebServiceRequ
> +
> + >>> from zope.interface import alsoProvides
> + >>> for cls, version in ((IWebServiceRe
> + ... (IWebServiceReq
> + ... (IWebServiceReq
> + ... alsoProvides(cls, IVersionedClien
> + ... sm.registerUtil
> + ... name=version)
> +
Can you explain the use of IVersionedClien tRequestImpleme ntation? You
explained on IRC that it to make it easy to retrieve the interface related to
a version string.
Would IVersionedWebCl ientRequestFact ory be a better name?
> +<<<<<<< TREE ICollection, name=version) dev_app, dev_request) api.multiversio n.dev/dev/
> >>> for version in ['beta', 'dev', '1.0']:
> ... sm.registerAdapter(
> ... ContactCollection, provided=
> @@ -397,3 +495,105 @@
> >>> print absoluteURL(
> http://
>
> +=======
You have a conflict marker here.
> +Collections web_service_ request( "/beta/ contact_ list") traverse( None) esource object at...>
> +===========
> +
> + >>> request = create_
> + >>> request.
> + <...CollectionR
> +>>>>>>> MERGE-SOURCE
Which ends here.
> === modified file 'src/lazr/ restful/ interfaces/ _rest.py'
> class IWebServiceClie ntRequest( IBrowserRequest ):
> - """Marker interface requests to the web service."""
> + """Interface for requests to the web service."""
> + version = Attribute("The version of the web service that the client "
> + "requested.")
Does this branch introduce that attribute? If it does, where is the doctest
example showing it's use?
> === modified file 'src/lazr/ restful/ publisher. py' restful/ publisher. py 2009-11-19 15:53:26 +0000 restful/ publisher. py 2010-01-06 17:40:25 +0000 urce) interfaces import ( ource, IWebBrowserInit iatedRequest, ource, tRequestImpleme ntation, IWebBrowserInit iatedRequest, ntRequest, IWebServiceConf iguration)
> --- src/lazr/
> +++ src/lazr/
> @@ -34,7 +34,12 @@
> EntryResource, ScopedCollection, ServiceRootReso
> from lazr.restful.
> IByteStorage, ICollection, ICollectionField, IEntry, IEntryField,
> +<<<<<<< TREE
> IHTTPResource, IServiceRootRes
> +=======
> + IHTTPResource, IServiceRootRes
> + IVersionedClien
> +>>>>>>> MERGE-SOURCE
> IWebServiceClie
Another conflict marker.
> # This object should not be published on the web service.
> + import pdb; pdb.set_trace()
> raise NotFound(ob, '')
Stray debugging.
> @@ -255,6 +261,7 @@ s[self. VERSION_ ANNOTATION] = version IServiceRootRes ource) n.application = service_root
> raise NotFound(self, '', self)
> self.annotation
>
> +<<<<<<< TREE
> # Find the appropriate service root for this version and set
> # the publication's application appropriately.
> try:
> @@ -265,6 +272,32 @@
> service_root = getUtility(
> self.publicatio
>
> +=======
More conflict markers.