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

Anthony Ventimiglia aventimiglia at common-lisp.net
Thu Oct 2 17:43:06 UTC 2003


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

Modified Files:
	cgi.lisp ChangeLog 
Log Message:
(a-list-value): Convenience macro for getting the
values of a-lists

Date: Thu Oct  2 13:43:06 2003
Author: aventimiglia

Index: clhp/cgi.lisp
diff -u clhp/cgi.lisp:1.3 clhp/cgi.lisp:1.4
--- clhp/cgi.lisp:1.3	Wed Oct  1 10:32:45 2003
+++ clhp/cgi.lisp	Thu Oct  2 13:43:06 2003
@@ -1,5 +1,5 @@
 (ext:file-comment
- "$Id: cgi.lisp,v 1.3 2003/10/01 14:32:45 aventimiglia Exp $")
+ "$Id: cgi.lisp,v 1.4 2003/10/02 17:43:06 aventimiglia Exp $")
 ;;
 ;; CLHP the Common Lisp Hypertext Preprocessor
 ;; (C) 2003 Anthony J Ventimiglia
@@ -42,6 +42,10 @@
 ex: (EXPLODE-STRING (\"Hello\") --> (#\H #\e #\l #\l #\o)"
   `(concatenate 'list ,string))
 
+(defmacro a-list-value (key a-list)
+  "returns the value from a (KEY . VALUE) A-LIST"
+  `(cdr (assoc ,key ,a-list)))
+
 ;; External Symbol section
 
 (defvar *server-env* nil
@@ -89,7 +93,8 @@
   (setf *server-env* ext:*environment-list*
 	*query-vars*
 	(let ((request-method (make-keyword
-			       (cdr (assoc :REQUEST_METHOD *server-env*)))))
+			       (a-list-value :REQUEST_METHOD
+					     *server-env*))))
 	  (cond
 	   ((eql request-method :POST)
 	    (query-to-a-list (post-data)))
@@ -147,8 +152,7 @@
 
 (defun get-data ()
   "Returns GET data (QUERY_STRING) as an exploded string"
-  (explode-string
-   (cdr (assoc :QUERY_STRING *server-env*))))
+  (explode-string (a-list-value :QUERY_STRING *server-env*)))
 
 ;; The closure makes sure we don't try to read from stdin twice
 (let ((get-switch nil)
@@ -161,7 +165,7 @@
 	       get-switch t
 	       post-char-list (read-n-chars
 			       (read-from-string
-				(cdr (assoc :CONTENT_LENGTH *server-env*)))))
+				(a-list-value :CONTENT_LENGTH *server-env*))))
 	      post-char-list)
 	  post-char-list)))
 


Index: clhp/ChangeLog
diff -u clhp/ChangeLog:1.5 clhp/ChangeLog:1.6
--- clhp/ChangeLog:1.5	Wed Oct  1 15:12:21 2003
+++ clhp/ChangeLog	Thu Oct  2 13:43:06 2003
@@ -1,3 +1,8 @@
+2003-10-02    <ant at afghan.dogpound>
+
+	* cgi.lisp (a-list-value): Convenience macro for getting the
+	values of a-lists
+
 2003-10-01    <ant at afghan.dogpound>
 
 	* tests/cgi-test.lisp: Beginning tests for CGI package, right now





More information about the Clhp-cvs mailing list