Commits

Christian Scholz committed 3a84e6f

added a ``render_wsgi()`` method to the ``Page`` object for making it easier to use WSGI for serving pages

  • Participants
  • Parent commits 5e56d8b

Comments (0)

Files changed (1)

File quantumcore/dynamicpage/page.py

         store in ``active_variant`` which usually was set by the ``render()``method."""
         return self.render_slot(slotname, self.active_variant)
         
-        
+    def render_wsgi(self, 
+                    environ, 
+                    start_response, 
+                    variant = None, 
+                    template = None, 
+                    encoding="utf-8"):
+        """render the template in WSGI form with setting the appropriate headers"""
+        data = self(variant=variant, template=template).encode(encoding)
+        headers = {'Content-Type': 'text/html',
+                   'Content-Length' : str(len(data))}
+        start_response("200 Ok", headers.items())
+        return data,