[Twisted-Python] IResource and http.Site()
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()? Thanks! -- Jon Parise (jon of csh.rit.edu) :: http://www.csh.rit.edu/~jon/
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/
Jon Parise wrote:
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)
... which is what it's actually doing. I'm so sorry - I misread resource.getChildForRequest() for Resource.getChildForRequest(). My code is causing a different but related error, and I went down the wrong path. Apologies for jumping the gun on this one! It must be the heat. =) -- Jon Parise (jon of csh.rit.edu) :: http://www.csh.rit.edu/~jon/
participants (1)
-
Jon Parise