[PATCH 2/2] Fix iteration of brokers at path /
Kambiz Darabi
darabi at m-creations.com
Mon Jun 15 23:33:18 UTC 2015
Hi,
this fixes the failing test in the previous patch for
applications/brokers which are located at /, either because path-of
application is nil, or the broker has a path of /.
Thanks
Kami
---
source/application/application.lisp | 10 ++++++++++
source/application/entry-point.lisp | 4 ++++
source/server/brokers.lisp | 6 ++++--
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/source/application/application.lisp b/source/application/application.lisp
index aa1998d..4524ea4 100644
--- a/source/application/application.lisp
+++ b/source/application/application.lisp
@@ -36,6 +36,16 @@
(ajax-enabled *default-ajax-enabled* :type boolean :accessor ajax-enabled? :export :accessor))
(:default-initargs :path '()))
+(def method call-if-matches-request ((app application) request thunk)
+ (let ((*application* app))
+ (call-next-method)))
+
+(def method handle-request ((app application) request)
+ (debug-only (assert (and (boundp '*broker-stack*) (eq (first *broker-stack*) app))))
+ (let ((*application* app))
+ ;; tell ITERATE-BROKERS-FOR-RESPONSE to go on with a new set of brokers
+ (remove-if-not (lambda (ep) (typep ep 'broker)) (entry-points-of app))))
+
(def (function e) make-frame-root-component (&optional content)
(make-frame-root-component-using-application *application* *session* *frame* content))
diff --git a/source/application/entry-point.lisp b/source/application/entry-point.lisp
index 89d15c7..cc2d808 100644
--- a/source/application/entry-point.lisp
+++ b/source/application/entry-point.lisp
@@ -85,6 +85,10 @@
(with-action-logic (:requires-valid-action requires-valid-action)
(-body-))
(-body-))
+ (unless (boundp '*session*)
+ (setf *session* nil))
+ (unless (boundp '*frame*)
+ (setf *frame* nil))
(call-in-post-action-environment *application* *session* *frame*
(named-lambda call-in-post-action-environment-body ()
(convert-to-primitive-response
diff --git a/source/server/brokers.lisp b/source/server/brokers.lisp
index 51d8466..d9f0614 100644
--- a/source/server/brokers.lisp
+++ b/source/server/brokers.lisp
@@ -81,7 +81,9 @@
;; record the broker who provided the new set of brokers on the *broker-stack*
(bind ((*broker-stack* (cons broker *broker-stack*)))
(server.debug "Broker ~A returned the new rules ~S, calling ITERATE-BROKERS-FOR-RESPONSE recursively" broker result)
- (iterate-brokers-for-response visitor request initial-brokers result (1+ recursion-depth))))
+ (iter (for broker :in result)
+ (aif (iterate-brokers-for-response visitor request initial-brokers (list broker) (1+ recursion-depth))
+ (return (values it))))))
(request
(server.debug "Broker ~A returned the new request ~S, calling ITERATE-BROKERS-FOR-RESPONSE recursively" broker result)
;; we've got a new request, start over using the original set of brokers
@@ -144,7 +146,7 @@
(def method call-if-matches-request ((broker broker-at-path) request thunk)
(bind ((broker-path (path-of broker))
(broker-path-length (length broker-path))
- (length-matches? (if (zerop broker-path-length)
+ (length-matches? (if (and broker-path (zerop broker-path-length))
(length= 0 *remaining-query-path-elements*)
(<= broker-path-length
(length *remaining-query-path-elements*)))))
--
1.9.1
More information about the cl-dwim-devel
mailing list