1 (in-package :lisp-on-lines-ucw
)
3 (defmacro dlambda
((&rest args
) &body body
)
5 `(let ((,env
(capture-dynamic-environment)))
7 (with-dynamic-environment (,env
)
10 (defclass contextl-application
(standard-application)
14 :action-class
'contextl-action
))
16 (defclass contextl-action
(ucw-standard:standard-action
)
17 ((dynamic-environment :accessor action-dynamic-environment
19 :initarg
:dynamic-environment
))
20 (:metaclass closer-mop
:funcallable-standard-class
))
22 (defmethod shared-initialize :after
((action contextl-action
) slots
&rest args
)
23 (declare (ignore slots args
))
24 (setf (action-dynamic-environment action
) (capture-dynamic-environment)))
26 (defmethod ucw-core:handle-action
:wrap-around
((action contextl-action
) application session frame
)
29 (defmethod ucw-core:call-action
:around
((action contextl-action
) application session frame
)
30 (with-dynamic-environment ((action-dynamic-environment action
))
33 (defmethod ucw-core:call-callbacks
:around
((action contextl-action
) frame request
)
34 (with-dynamic-environment ((action-dynamic-environment action
))
37 (defclass contextl-component
(standard-component)
38 ((component-dynamic-environment :accessor component-dynamic-environment
40 (:metaclass standard-component-class
))
42 (defmethod render :wrap-around
((component contextl-component
))
43 (if (component-dynamic-environment component
)
44 (with-dynamic-environment ((component-dynamic-environment component
))
46 (progn (setf (component-dynamic-environment component
) (capture-dynamic-environment))
49 (defmethod/cc call-component
:before
((from t
) (to contextl-component
))
50 (setf (component-dynamic-environment to
) (capture-dynamic-environment)))
56 (defclass contextl-test-application
(contextl-application)
58 (:default-initargs
:url-prefix
"/contextl/"))
60 (defparameter *context-test-application
* (make-instance 'contextl-test-application
))
62 (register-application ucw-user
:*example-server
* *context-test-application
*)
64 (defentry-point "test.ucw" (:application
*context-test-application
*) ()
65 (call 'contextl-test-component
))
69 (defclass contextl-test-component
(contextl-component) ()
70 (:metaclass standard-component-class
))
72 (defmethod render ((component contextl-test-component
))
73 (<:As-html
(dynamic foo
))
74 (dlet ((foo (1+ (dynamic foo
))))
75 (<:as-html
(dynamic foo
))
77 (with-described-object (T nil
)
78 (let ((a (find-attribute *description
* 'identity
)))
79 (<ucw
:a
:action
(call 'contextl-test-component
)
82 (when (component.calling-component component
)
83 (<ucw
:a
:action
(answer)
102 #+nil
(defclass contextl-session-frame
(ucw-core::standard-session-frame
)
105 #+nil
(defmethod ucw-core::register-callback-in-frame
((frame contextl-session-frame
) callback
&key
&allow-other-keys
)
106 (let ((lambda (ucw::callback-lambda callback
)))
107 (let ((context (contextl:current-layer-context
)))
108 (setf (ucw::callback-lambda callback
)
110 (contextl:funcall-with-layer-context context lambda arg
)))
111 (call-next-method))))
113 #+nil
(setf ucw-core
::*session-frame-class
* 'contextl-session-frame
)