From 3e423cb89e5838ab11edb6f128331ebbc8b85f4e Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Sun, 16 Nov 2003 18:47:29 +0000 Subject: [PATCH] r8231: add support for maps --- classes.lisp | 2 ++ project.lisp | 55 ++++++++++++++++++++++++++++++---------------------- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/classes.lisp b/classes.lisp index 90b868b..a11e888 100644 --- a/classes.lisp +++ b/classes.lisp @@ -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))) diff --git a/project.lisp b/project.lisp index cf8c191..ea38c8a 100644 --- a/project.lisp +++ b/project.lisp @@ -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 @@ -222,36 +222,45 @@ (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) -- 2.34.1