r8231: add support for maps
authorKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 16 Nov 2003 18:47:29 +0000 (18:47 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 16 Nov 2003 18:47:29 +0000 (18:47 +0000)
classes.lisp
project.lisp

index 90b868b9e2379fddbc9e046c830e4ddfbc03b9db..a11e8886abb3d729af6cdafa450dd6fce9b251e5 100644 (file)
@@ -48,6 +48,8 @@
 
 (defclass entity ()
   ((project :initarg :project :accessor entity-project)
+   (generators :initarg :generators :accessor entity-generators
+              :documentation "List of waiting page generators")
    (aserve-entity :initarg :aserve-entity :initform nil
                  :accessor entity-aserve-entity)))
 
index cf8c1910c44ddc516a34ec452a5151241d4d7fc0..ea38c8a28c54618dd74e0314092b0559e7bf0c28 100644 (file)
@@ -45,7 +45,7 @@
 
     (let ((hash (make-hash-table :size (length map) :test 'equal)))
       (dolist (map-item map)
-       (setf (gethash (first map-item) hash) (second map-item)))
+       (setf (gethash (first map-item) hash) (cdr map-item)))
       (setf (project-hash-map project) hash))
 
     (ecase connector
 
 
 (defun dispatch-to-handler (req ent)
-  (let ((handler (request-find-handler req ent))
+  (let ((handlers (request-find-handlers req ent))
        (*wol-stream* (request-socket req)))
-    (if handler
-       (handle-request handler req ent)
+    (if handlers
+       (handle-request handlers req ent)
       (no-url-handler req ent))))
 
-(defun request-find-handler (req ent)
+(defun request-find-handlers (req ent)
   (nth-value 0 (gethash (request-page req) 
                        (project-hash-map (entity-project ent)))))
 
-(defun handle-request (handler req ent)
-  (typecase handler
+(defun handle-request (handlers req ent)
+  (typecase handlers
     (null
+     (setf (entity-generators ent) nil)
      nil)
-    ((or symbol function)
-     (when (and (symbolp handler)
-               (not (fboundp handler)))
-       (cmsg "handler given a symbol without a function ~S" handler)
-       (return-from handle-request nil))
-     (let ((next-page (funcall handler req ent)))
-       (typecase next-page
-        (string
-         (redirect-entity next-page req ent))
-        (cons
-         (redirect-entity (car next-page) req ent (cadr next-page)))
-        (null
-         t)
-        (t
-         (cmsg "handler should return nil or a string, not ~S" next-page))))
-     t)
+    (list
+     (let ((next-handler (first handlers)))
+       (setf (entity-generators ent) (cdr handlers))
+       (when (and (symbolp next-handler)
+                 (not (fboundp next-handler)))
+        (cmsg "handler given a symbol without a function ~S" next-handler)
+        (return-from handle-request nil))
+       (let ((next-page (funcall next-handler req ent)))
+        (typecase next-page
+          (string
+           (setf (entity-generators ent) nil)
+           (redirect-entity next-page req ent))
+          (cons
+           (setf (entity-generators ent) nil)
+           (redirect-entity (car next-page) req ent (cadr next-page)))
+          (keyword
+           (if (eq :continue next-page)
+               (handle-request (cdr handlers) req ent)
+               (add-log-entry "Invalid return keyword ~S" next-page)))
+          (null
+           t)
+          (t
+           (cmsg "handler should return nil or a string, not ~S" next-page))))
+       t))
     (string
      (cmsg "string handler not supported: ~A" handler)
      nil)