|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Multiple RESTful ViewsHi there,
It appears that a REST view doesn't work quite like other views; each method (GET/POST/PUT/DELETE) is a view itself. This is a problem for me because i'd like to provide many different RESTful interfaces for the same content type. Is this pattern discouraged or is there a workaround that you guys know of? I cannot seem to do this: ---------------------%<---------------------- class DefaultREST(grok.REST): grok.layer(IRestLayer) grok.name('default') grok.context(IFooContext) def GET(self): .... class AlternateREST(grok.REST): grok.layer(IRestLayer) grok.name('alternate') grok.context(IFooContext) def GET(self): ..... ConfigurationConflictError: Conflicting configuration actions ---------------------%<---------------------- Any hints appreciated! Regards, Paul _______________________________________________ Grok-dev mailing list Grok-dev@... https://mail.zope.org/mailman/listinfo/grok-dev |
|
|
Re: Multiple RESTful ViewsPaul Wilson wrote:
> It appears that a REST view doesn't work quite like other views; each > method (GET/POST/PUT/DELETE) is a view itself. > > This is a problem for me because i'd like to provide many different > RESTful interfaces for the same content type. Is this pattern > discouraged or is there a workaround that you guys know of? > > I cannot seem to do this: > > ---------------------%<---------------------- > class DefaultREST(grok.REST): > grok.layer(IRestLayer) > grok.name('default') > grok.context(IFooContext) > > def GET(self): > .... > > class AlternateREST(grok.REST): > grok.layer(IRestLayer) > grok.name('alternate') > grok.context(IFooContext) > > def GET(self): > ..... > > ConfigurationConflictError: Conflicting configuration actions > ---------------------%<---------------------- > > Any hints appreciated! The key is the grok.layer(IRestLayer). If you want to have two REST APIs available for you objects, you should register each for a separate layer, derived from the IRestLayer. class IRestAPIOne(IRestLayer): grok.restskin('default') class IRestAPITwo(IRestLayer): grok.restskin('alternate') class DefaultREST(grok.REST): grok.layer(IRestAPIOne) grok.name('default') grok.context(IFooContext) def GET(self): .... class AlternateREST(grok.REST): grok.layer(IRestAPITwo) grok.name('alternate') grok.context(IFooContext) def GET(self): ..... See also the ftests of Grok itself for more hints: http://svn.zope.org/grok/trunk/src/grok/ftests/rest/rest.py?view=markup HTH. regards, jw _______________________________________________ Grok-dev mailing list Grok-dev@... https://mail.zope.org/mailman/listinfo/grok-dev |
|
|
Re: Multiple RESTful Views2009/9/24 Jan-Wijbrand Kolman <janwijbrand@...>:
> The key is the grok.layer(IRestLayer). If you want to have two REST APIs > available for you objects, you should register each for a separate > layer, derived from the IRestLayer. Thanks! I must have been tired last night because the REST tutorial clearly covers this but I still managed to miss it! Paul _______________________________________________ Grok-dev mailing list Grok-dev@... https://mail.zope.org/mailman/listinfo/grok-dev |
| Free embeddable forum powered by Nabble | Forum Help |