[Grok-dev] Re: REST branch ready for review
Jan-Wijbrand Kolman
janwijbrand at gmail.com
Wed Oct 17 08:04:50 EDT 2007
Martijn Faassen wrote:
> To actually issue REST requests over a URL, you need to define a REST
> protocol that uses this layer:
After reading and trying it is not clear to me what the relationship is
between the "layer" and the "protocol" components. Can you elaborate on
this?
For example, I played around with this code:
import grok
class TestRest(grok.Application, grok.Container):
pass
class Index(grok.View):
pass # see app_templates/index.pt
class FirstLayer(grok.IRESTLayer):
pass
class SecondLayer2(grok.IRESTLayer):
pass
class FirstREST(grok.REST):
grok.context(TestRest)
def GET(self):
return 'GET' + repr(self)
class SecondREST(grok.REST):
grok.context(TestRest)
def GET(self):
return 'SECOND GET' + repr(self)
class FirstProtocol(grok.RESTProtocol):
grok.layer(FirstLayer)
grok.name('foobar')
And now if I go to
http://localhost:8080/++rest++foobar/mytestrestinstance
I get:
SECOND GET<grok.meta.SecondREST object at ...>
Why do I get to the "SecondREST" view here?
And shouldn't Grok complain about the fact that I have created two
layers, but I do not have explicit use a grok.layer() directive in my
grok.REST subclasses?
regards,
jw
More information about the Grok-dev
mailing list