[clhp-cvs] CVS update: clhp/package.lisp clhp/cgi.lisp clhp/TODO clhp/ChangeLog

Anthony Ventimiglia aventimiglia at common-lisp.net
Tue Oct 21 04:16:59 UTC 2003


Update of /project/clhp/cvsroot/clhp
In directory common-lisp.net:/tmp/cvs-serv8963

Modified Files:
	package.lisp cgi.lisp TODO ChangeLog 
Log Message:
* examples/index.clhp (PRINT-HASH-TO-TABLE): Modified to work with
new hash-tables

* examples/test.lisp (PRINT-HASH): Modified test program to work
with new hash-table

* cgi.lisp (*SERVER-ENV*,*QUERY-VARS*): Converted to hashtable.

Date: Tue Oct 21 00:16:58 2003
Author: aventimiglia

Index: clhp/package.lisp
diff -u clhp/package.lisp:1.1 clhp/package.lisp:1.2
--- clhp/package.lisp:1.1	Fri Oct 17 08:58:04 2003
+++ clhp/package.lisp	Tue Oct 21 00:16:58 2003
@@ -1,4 +1,4 @@
-#+cmu (ext:file-comment "$Id: package.lisp,v 1.1 2003/10/17 12:58:04 aventimiglia Exp $")
+#+cmu (ext:file-comment "$Id: package.lisp,v 1.2 2003/10/21 04:16:58 aventimiglia Exp $")
 ;;
 ;; CLHP the Common Lisp Hypertext Preprocessor
 ;; (C) 2003 Anthony J Ventimiglia
@@ -24,7 +24,7 @@
 
 (defpackage #:net.common-lisp.aventimiglia.clhp
   (:nicknames #:clhp #:cgi)		; The CGI will go away eventually
-  (:use #:cl)
+  (:use #:cl #:ext)
   (:export #:*server-env* #:*query-vars* #:header #:debug #:init
 	   #:parse #:*clhp-version* #:echo #:include #:xml-element
 	   #:make-xml-element #:copy-xml-element #:xml-element-attributes


Index: clhp/cgi.lisp
diff -u clhp/cgi.lisp:1.12 clhp/cgi.lisp:1.13
--- clhp/cgi.lisp:1.12	Fri Oct 17 09:11:44 2003
+++ clhp/cgi.lisp	Tue Oct 21 00:16:58 2003
@@ -1,4 +1,4 @@
-#+cmu (ext:file-comment "$Id: cgi.lisp,v 1.12 2003/10/17 13:11:44 aventimiglia Exp $")
+#+cmu (ext:file-comment "$Id: cgi.lisp,v 1.13 2003/10/21 04:16:58 aventimiglia Exp $")
 ;;
 ;; CLHP the Common Lisp Hypertext Preprocessor
 ;; (C) 2003 Anthony J Ventimiglia
@@ -24,7 +24,7 @@
 
 (defmacro debug (expression)
   "Print out EXPRESSION and the result of (EVAL EXPRESSION)"
-  `(format t "(CGI:DEBUG: ~s --> ~s)~%" ,expression (eval ,expression)))
+  `(format t "(CLHP:DEBUG: ~s --> ~s)~%" ,expression (eval ,expression)))
 
 (defmacro explode-string (string)
   "Converts a string to a list of chars, this is an aux function used
@@ -34,18 +34,13 @@
 
 ;; External Symbol section
 
-(defvar *server-env* nil
-  "This is an a-list of all environment variables passed by the
-server, the CAR of each cons in the a-list is a keyword, and all
-values are stored as strings, which should be converted if
-necessary. Accessing would be something like the following: (ASSOC
-:REQUEST_METHOD *SERVER-ENV*)")
-
-(defvar *query-vars* nil
-  "An a-list of all variables passed through a GET or POST method, the
-CAR of each cons in the a-list is a keyword, and all data is kept in
-string form so conversion may be necessary. Accessing would be as
-follows: (ASSOC :FOO *QUERY-VARS*)")
+(defvar *server-env* (make-hash-table)
+  "This is a hash-table variables passed by the thw key is a keyword
+and all values are stored as strings.")
+
+(defvar *query-vars* (make-hash-table)
+  "A hash-table of all variables passed through a GET or POST method, the
+key is a string, and all values are stored in string form.")
 
 ;; This will obviously be improved upon to handle different content
 ;; types, but for now it's just a stub to print plain text pages. It
@@ -75,17 +70,21 @@
 (defun init ()
   "Initialize CGI, this should be called before any globals are
 accessed"
-  (setf *server-env* (ca-list-to-a-list ext:*environment-list*)
-	*query-vars*
-	(cond-bind
-	 ((request-method (make-keyword
-			       (a-list-value :REQUEST_METHOD
-					     *server-env*))))
-	 ((eql request-method :POST)
-	  (query-to-a-list (post-data)))
-	 ((eql request-method :GET)
-	  (query-to-a-list (get-data)))))
-	(values))
+  (mapcar #'(lambda (key/val)
+	      (setf (gethash (car key/val) *server-env*)
+		    (cdr key/val)))
+	  *environment-list*)
+  (mapcar #'(lambda (key/val-list)
+	      (setf (gethash (car key/val-list) *query-vars*)
+		    (cadr key/val-list)))
+	  (cond-bind
+	   ((request-method (make-keyword
+			     (gethash :REQUEST_METHOD *server-env*))))
+	   ((eql request-method :POST)
+	    (query-to-a-list (post-data)))
+	   ((eql request-method :GET)
+	    (query-to-a-list (get-data)))))
+  (values))
 
 ;;
 ;; End of external symbols
@@ -137,7 +136,7 @@
 
 (defun get-data ()
   "Returns GET data (QUERY_STRING) as an exploded string"
-  (explode-string (a-list-value :QUERY_STRING *server-env*)))
+  (explode-string (gethash :QUERY_STRING *server-env*)))
 
 ;; The closure makes sure we don't try to read from stdin twice
 (let ((get-switch nil)
@@ -150,7 +149,7 @@
 	       get-switch t
 	       post-char-list (read-n-chars
 			       (read-from-string
-				(a-list-value :CONTENT_LENGTH *server-env*))))
+				(gethash :CONTENT_LENGTH *server-env*))))
 	      post-char-list)
 	  post-char-list)))
 
@@ -220,5 +219,5 @@
 text header, echoing the error-message."
   (header :content-type :text/plain)
   (format t "CL-CGI: ~A~%" (error-message condition))
-  (ext:quit))
+  (quit))
 


Index: clhp/TODO
diff -u clhp/TODO:1.8 clhp/TODO:1.9
--- clhp/TODO:1.8	Fri Oct 17 08:58:04 2003
+++ clhp/TODO	Tue Oct 21 00:16:58 2003
@@ -1,16 +1,16 @@
-$Id: TODO,v 1.8 2003/10/17 12:58:04 aventimiglia Exp $ -*- outline -*-
-
-* Use ASDF for package building
-
-* Convert *QUERY-VARS* and *SERVER-ENV* to hashes
-  I should probably make interface functions to access them, actually
-  I should make them read-only maybe encapsulate a hash in a class and
-  only allow reading from external functions
+$Id: TODO,v 1.9 2003/10/21 04:16:58 aventimiglia Exp $ -*- outline -*-
 
 * Test suite
+**  Convert all this to new deal with single package.
+    Maybe make separate files for each function, or group of related
+    or interdependant files.
+
 **  Complete suite for :cgi
 **  Complete suite for :clhp
 **  Refine :test-suite
+
+* Declare Declaim and Proclaim
+  GO through everything and refine and type it all.
 
 * COMPILE-CGI 
   This is just a convenience function that will compile and save fasl


Index: clhp/ChangeLog
diff -u clhp/ChangeLog:1.17 clhp/ChangeLog:1.18
--- clhp/ChangeLog:1.17	Sat Oct 18 21:57:14 2003
+++ clhp/ChangeLog	Tue Oct 21 00:16:58 2003
@@ -1,3 +1,15 @@
+2003-10-21    <ant at afghan.dogpound>
+
+	* examples/index.clhp (PRINT-HASH-TO-TABLE): Modified to work with
+	new hash-tables
+
+2003-10-20    <ant at afghan.dogpound>
+
+	* examples/test.lisp (PRINT-HASH): Modified test program to work
+	with new hash-table
+
+	* cgi.lisp (*SERVER-ENV*,*QUERY-VARS*): Converted to hashtable.
+
 2003-10-18    <ant at afghan.dogpound>
 
 	* examples/test.lisp: Changed CGI: namespace to CLHP:, CGI: no
@@ -106,4 +118,4 @@
 	used to create tables from (CONS . TYPE) a-lists. Also added some
 	comments.
 
-$Id: ChangeLog,v 1.17 2003/10/19 01:57:14 aventimiglia Exp $
\ No newline at end of file
+$Id: ChangeLog,v 1.18 2003/10/21 04:16:58 aventimiglia Exp $
\ No newline at end of file





More information about the Clhp-cvs mailing list