[Twisted-Python] resource.render_METHOD

I have a server application that creates a number of web resources (derived from resource.Resource). Some of the resources only handle GET requests, while others only handle POSTs.
Currently the resources only override the render() method. I want to change them to override render_GET() or render_POST() as appropriate.
I notice that if a resource receives a request it doesn't handle, then an UnsupportedMethod exception is raised. This returns HTML to the client containing a message that uses UnsupportedMethod.allowedMethods. This defaults to an empty tuple.
Because my resources support different request methods, I have to set allowedMethods in each resource's render() method e.g.
def render(self, request): server.UnsupportedMethod.allowedMethods = ('POST',) resource.Resource.render(self, request)
So I still need to override the render() method.
Is there a neater way to do this?
I'm using Twisted 1.2.0
regards Richard Townsend

Richard.Townsend@edl.uk.eds.com wrote:
I notice that if a resource receives a request it doesn't handle, then an UnsupportedMethod exception is raised. This returns HTML to the client containing a message that uses UnsupportedMethod.allowedMethods. This defaults to an empty tuple.
Is there a neater way to do this?
Hmm. I suppose render() could grope through methods on self to find all 'render_FOO' methods when an exception occurs.. OTOH, we could just get rid of the allowed methods reporting. What's the use?
participants (2)
-
Christopher Armstrong
-
Richard.Townsend@edl.uk.eds.com