Revision: 3720
Author: ksprotte
URL: http://bknr.net/trac/changeset/3720
BKNR web: QUERY-PARAM and WITH-QUERY-PARAMS now support conversion
from the value string to an optionally specified type.
U trunk/bknr/web/src/web/web-macros.lisp
U trunk/bknr/web/src/web/web-utils.lisp
Modified: trunk/bknr/web/src/web/web-macros.lisp
===================================================================
--- trunk/bknr/web/src/web/web-macros.lisp 2008-08-01 12:08:44 UTC (rev 3719)
+++ trunk/bknr/web/src/web/web-macros.lisp 2008-08-01 12:50:18 UTC (rev 3720)
@@ -19,20 +19,31 @@
names)
,@body))
-(defmacro with-query-params ((&rest params) &body body)
- (let ((vars (loop for param in params
- when (and (symbolp param)
- (not (null param)))
- collect (list param `(query-param ,(string-downcase (symbol-name param))))
- when (consp param)
- collect (list (car param)
- `(or (parameter ,(string-downcase (symbol-name (car param))))
- ,(second param))))))
- (if vars
- `(let ,vars
- ,@body)
- (first body))))
+(defmacro with-query-params ((&rest parameters) &body body)
+ "PARAMETERS is a list of parameter-specifiers. A parameter-specifier
+has the form (VARIABLE &OPTIONAL DEFAULT-VALUE TYPE) or can be a
+single VARIABLE.
+If the TYPE is specified, the value is converted like in
+HUNCHENTOOT:DEFINE-EASY-HANDLER when PARAMETER-TYPE is given.
+
+With respect to the conversion of an empty string, there is a subtle
+difference between the TYPE specified as STRING and the TYPE left
+unspecified. In the former case, the converted value will still be an
+empty string, while in the latter VARIABLE will be bound to NIL."
+ (flet ((parameter-binding (parameter-specifier)
+ (destructuring-bind (variable &optional default-value type)
+ (ensure-list parameter-specifier)
+ (let ((query-param-form (if type
+ `(query-param ,(string-downcase variable) :type ',type)
+ `(query-param ,(string-downcase variable)))))
+ `(,variable
+ ,(if default-value
+ `(or ,query-param-form ,default-value)
+ query-param-form))))))
+ `(let ,(mapcar #'parameter-binding parameters)
+ ,@body)))
+
(defmacro form-case (&rest cases)
`(cond
,@(mapcar #'(lambda (c)
Modified: trunk/bknr/web/src/web/web-utils.lisp
===================================================================
--- trunk/bknr/web/src/web/web-utils.lisp 2008-08-01 12:08:44 UTC (rev 3719)
+++ trunk/bknr/web/src/web/web-utils.lisp 2008-08-01 12:50:18 UTC (rev 3720)
@@ -70,10 +70,12 @@
(append (when get (get-parameters*))
(when post (post-parameters*))))
-(defun query-param (param-name &key (get t) (post t))
+(defun query-param (param-name &key (get t) (post t) type)
(let ((value (cdr (assoc param-name (query-params :get get :post post) :test #'string-equal))))
- (unless (equal value "")
- value)))
+ (if type
+ (hunchentoot::convert-parameter value type)
+ (unless (equal value "")
+ value))))
(defun query-param-list (param-name &key (get t) (post t))
(assoc-values param-name (query-params :get get :post post)
Revision: 3718
Author: edi
URL: http://bknr.net/trac/changeset/3718
Tag version 1.0.5 of flexi-streams
A tags/thirdparty/flexi-streams-1.0.5/
Copied: tags/thirdparty/flexi-streams-1.0.5 (from rev 3717, trunk/thirdparty/flexi-streams)
Revision: 3717
Author: edi
URL: http://bknr.net/trac/changeset/3717
Update to 1.0.5
U trunk/thirdparty/flexi-streams/CHANGELOG
U trunk/thirdparty/flexi-streams/doc/index.html
U trunk/thirdparty/flexi-streams/flexi-streams.asd
U trunk/thirdparty/flexi-streams/test/packages.lisp
Modified: trunk/thirdparty/flexi-streams/CHANGELOG
===================================================================
--- trunk/thirdparty/flexi-streams/CHANGELOG 2008-08-01 06:57:30 UTC (rev 3716)
+++ trunk/thirdparty/flexi-streams/CHANGELOG 2008-08-01 10:14:17 UTC (rev 3717)
@@ -1,3 +1,7 @@
+Version 1.0.5
+2008-08-01
+Export RUN-ALL-TESTS instead of RUN-TESTS (caught by Nick Allen)
+
Version 1.0.4
2008-07-25
Cosmetic surgery on test suite
Modified: trunk/thirdparty/flexi-streams/doc/index.html
===================================================================
--- trunk/thirdparty/flexi-streams/doc/index.html 2008-08-01 06:57:30 UTC (rev 3716)
+++ trunk/thirdparty/flexi-streams/doc/index.html 2008-08-01 10:14:17 UTC (rev 3717)
@@ -229,7 +229,7 @@
<p>
FLEXI-STREAMS together with this documentation can be downloaded from <a
href="http://weitz.de/files/flexi-streams.tar.gz">http://weitz.de/files/flexi-streams.tar.gz</a>. The
-current version is 1.0.4.
+current version is 1.0.5.
<p>
Before you install FLEXI-STREAMS you first need to
install the <a
@@ -1114,7 +1114,7 @@
his work on making FLEXI-STREAMS faster.
<p>
-$Header: /usr/local/cvsrep/flexi-streams/doc/index.html,v 1.123 2008/07/25 09:57:00 edi Exp $
+$Header: /usr/local/cvsrep/flexi-streams/doc/index.html,v 1.124 2008/08/01 10:12:41 edi Exp $
<p><a href="http://weitz.de/index.html">BACK TO MY HOMEPAGE</a>
</body>
Modified: trunk/thirdparty/flexi-streams/flexi-streams.asd
===================================================================
--- trunk/thirdparty/flexi-streams/flexi-streams.asd 2008-08-01 06:57:30 UTC (rev 3716)
+++ trunk/thirdparty/flexi-streams/flexi-streams.asd 2008-08-01 10:14:17 UTC (rev 3717)
@@ -1,5 +1,5 @@
;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*-
-;;; $Header: /usr/local/cvsrep/flexi-streams/flexi-streams.asd,v 1.76 2008/07/25 09:56:58 edi Exp $
+;;; $Header: /usr/local/cvsrep/flexi-streams/flexi-streams.asd,v 1.77 2008/08/01 10:12:40 edi Exp $
;;; Copyright (c) 2005-2008, Dr. Edmund Weitz. All rights reserved.
@@ -35,7 +35,7 @@
(in-package :flexi-streams-system)
(defsystem :flexi-streams
- :version "1.0.4"
+ :version "1.0.5"
:serial t
:components ((:file "packages")
(:file "mapping")
Modified: trunk/thirdparty/flexi-streams/test/packages.lisp
===================================================================
--- trunk/thirdparty/flexi-streams/test/packages.lisp 2008-08-01 06:57:30 UTC (rev 3716)
+++ trunk/thirdparty/flexi-streams/test/packages.lisp 2008-08-01 10:14:17 UTC (rev 3717)
@@ -1,5 +1,5 @@
;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*-
-;;; $Header: /usr/local/cvsrep/flexi-streams/test/packages.lisp,v 1.6 2008/05/17 16:38:26 edi Exp $
+;;; $Header: /usr/local/cvsrep/flexi-streams/test/packages.lisp,v 1.8 2008/08/01 10:12:43 edi Exp $
;;; Copyright (c) 2006-2008, Dr. Edmund Weitz. All rights reserved.
@@ -36,4 +36,4 @@
:with-rebinding
:char*
:normalize-external-format)
- (:export :run-tests))
+ (:export :run-all-tests))