Browse Source

support other response types in proxy object

Darren Ranalli 16 years ago
parent
commit
efca6018ed
1 changed files with 14 additions and 3 deletions
  1. 14 3
      direct/src/http/WebRequest.py

+ 14 - 3
direct/src/http/WebRequest.py

@@ -72,12 +72,15 @@ class SkinningReplyTo:
         self._headTags = self._dispatcher._headTags[:]
         self._headTags = self._dispatcher._headTags[:]
         self._dispatcher._clearHeadTags()
         self._dispatcher._clearHeadTags()
 
 
-    def respond(self, response):
+    def respondHTTP(self,status,body):
         if self._doSkin:
         if self._doSkin:
             self._addHeadTags()
             self._addHeadTags()
-            response = self._dispatcher.landingPage.skin(response, self._uri)
+            body = self._dispatcher.landingPage.skin(body, self._uri)
             self._removeHeadTags()
             self._removeHeadTags()
-        self._replyTo.respond(response)
+        self._replyTo.respondHTTP(status, body)
+
+    def respond(self, response):
+        self.respondHTTP("200 OK", response)
 
 
     def addTagToHead(self, tag):
     def addTagToHead(self, tag):
         self._headTags.append(tag)
         self._headTags.append(tag)
@@ -92,6 +95,14 @@ class SkinningReplyTo:
         for tag in self._headTags:
         for tag in self._headTags:
             head.remove(tag)
             head.remove(tag)
 
 
+    def __getattr__(self, attrName):
+        if not hasattr(self, attrName):
+            # pass-through to replyTo object which this object is a proxy to
+            return getattr(self._replyTo, attrName)
+        if attrName in self.__dict__:
+            return self.__dict__[attrName]
+        return getattr(self.__class__, attrName)
+
 class WebRequestDispatcher(object):
 class WebRequestDispatcher(object):
     """
     """
     Request dispatcher for HTTP requests.
     Request dispatcher for HTTP requests.