[Twisted-Python] IResource and http.Site()

Jon Parise jon at csh.rit.edu
Mon Aug 14 22:28:25 EDT 2006


Jon Parise wrote:
> I'm relatively new to Twisted, so apologies if I'm missing something
> obvious.  I'm using Twisted 2.4, and I'm trying to use twisted.web with 
> my own resource implementation.
> 
> It looks like my options are to either derive from http.Resource or 
> implement the http.IResource interface directly.  I've decided to start 
> with the latter.
> 
> The IResource interface declares three methods:
> 
>     getChildWithDefault(self, name, request)
>     putChild(self, path, child)
>     render(self, request)
> 
> However, parts of http.Site() (such as getResourceFor()) expect my 
> object to offer additional methods (such as getChildForRequest()) which 
> are not part of the interface.
> 
> My question is therefore: Is http.Site() only compatible with Resource 
> (and not IResource), or should the IResource interface include some 
> additional methods, such as getChildForRequest()?

Or perhaps Door Number 3:

Should http.Site() be updated to use the module-level 
http.getChildForRequest() instead of Resource.getChildForRequest(), as 
suggested by this code in Resource.getChildForRequest():

      def getChildForRequest(self, request):
          import warnings
          warnings.warn("Please use module level getChildForRequest.", 
DeprecationWarning, 2)
          return getChildForRequest(self, request)

-- 
Jon Parise (jon of csh.rit.edu)  ::  http://www.csh.rit.edu/~jon/




More information about the Twisted-Python mailing list