<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>resource.render_METHOD </TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>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.</FONT></P>

<P><FONT SIZE=2>Currently the resources only override the render() method. I want to change them to override render_GET() or render_POST() as appropriate.</FONT></P>

<P><FONT SIZE=2>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. </FONT></P>

<P><FONT SIZE=2>Because my resources support different request methods, I have to set allowedMethods in each resource's render() method e.g.</FONT></P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp; def render(self, request):</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; server.UnsupportedMethod.allowedMethods = ('POST',)</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; resource.Resource.render(self, request)</FONT>
</P>

<P><FONT SIZE=2>So I still need to override the render() method. </FONT>
</P>

<P><FONT SIZE=2>Is there a neater way to do this?</FONT>
</P>

<P><FONT SIZE=2>I'm using Twisted 1.2.0</FONT>
</P>

<P><FONT SIZE=2>regards</FONT>
<BR><FONT SIZE=2>Richard Townsend</FONT>
</P>

</BODY>
</HTML>