[cvs-annodex] commit (/annodex): annodex-validator/trunk/anxvalidator/page.py annodex-validator/trunk/anxvalidator/static.py annodex-validator/trunk/anxvalidator/validate.py +annodex-validator/trunk/anxvalidator/response.py

conrad nobody at lists.annodex.net
Sun Feb 12 21:52:12 EST 2006


Update of /annodex (new revision 2035)

Added files:
   annodex-validator/trunk/anxvalidator/response.py

Modified files:
   annodex-validator/trunk/anxvalidator/page.py
   annodex-validator/trunk/anxvalidator/static.py
   annodex-validator/trunk/anxvalidator/validate.py

Log Message:
add response class to handle HTTP headers+content, adds Content-Length header
for generated html


Modified: annodex-validator/trunk/anxvalidator/page.py
===================================================================
--- annodex-validator/trunk/anxvalidator/page.py	2006-02-11 08:36:42 UTC (rev 2034)
+++ annodex-validator/trunk/anxvalidator/page.py	2006-02-12 10:52:12 UTC (rev 2035)
@@ -17,10 +17,11 @@
   def __init__(self, o):
     self.o = o
 
+  def content_type(self):
+    return 'text/html; charset=utf-8'
+
   def __str__(self):
-    return '''Content-Type: text/html; charset=utf-8
-
-<?xml version="1.0"?>
+    return '''<?xml version="1.0"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

Added: annodex-validator/trunk/anxvalidator/response.py
===================================================================
--- annodex-validator/trunk/anxvalidator/response.py	2006-02-11 08:36:42 UTC (rev 2034)
+++ annodex-validator/trunk/anxvalidator/response.py	2006-02-12 10:52:12 UTC (rev 2035)
@@ -0,0 +1,28 @@
+# -*- coding: iso8859-1 -*-
+#
+# Copyright (C) 2006 CSIRO Australia
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For exact contribution history, see the revision
+# history and logs.
+#
+# Author: Conrad Parker <conrad at annodex.net>
+
+class Response (object):
+
+  def __init__(self, o):
+    self.o = o
+
+  def __str__(self):
+    content_type = self.o.content_type()
+    content = self.o.__str__()
+    content_length = len(content)
+
+    return '''Content-Length: %d
+Content-Type: %s
+
+%s''' % (content_length, content_type, content)

Modified: annodex-validator/trunk/anxvalidator/static.py
===================================================================
--- annodex-validator/trunk/anxvalidator/static.py	2006-02-11 08:36:42 UTC (rev 2034)
+++ annodex-validator/trunk/anxvalidator/static.py	2006-02-12 10:52:12 UTC (rev 2035)
@@ -14,6 +14,7 @@
 
 from anxvalidator.page import Page
 from anxvalidator.about import About
+from anxvalidator.response import Response
 
 class Static (object):
 
@@ -22,6 +23,6 @@
 
   def __str__(self):
     if (self.page == 'about.html'):
-      return Page(About()).__str__()
+      return Response(Page(About())).__str__()
     else:
-      return Page("WTF?").__str__()
+      return Response(Page("WTF?")).__str__()

Modified: annodex-validator/trunk/anxvalidator/validate.py
===================================================================
--- annodex-validator/trunk/anxvalidator/validate.py	2006-02-11 08:36:42 UTC (rev 2034)
+++ annodex-validator/trunk/anxvalidator/validate.py	2006-02-12 10:52:12 UTC (rev 2035)
@@ -15,6 +15,7 @@
 from anxvalidator.form import Form
 from anxvalidator.result import Result
 from anxvalidator.page import Page
+from anxvalidator.response import Response
 
 class Validate (object):
 
@@ -32,6 +33,6 @@
 
   def __str__(self):
     if (self.uri):
-      return Page(Result(self.uri, self.force_media)).__str__()
+      return Response(Page(Result(self.uri, self.force_media))).__str__()
     else:
-      return Page(Form()).__str__()
+      return Response(Page(Form())).__str__()


-- 
conrad



More information about the cvs-annodex mailing list