[Bese-devel] isolated actions

Drew Crampsie drewc at tech.coop
Wed Apr 5 05:19:22 UTC 2006


Evrim ULU wrote:
> hi,
> 
> where do we use isolated actions in practice?

Isolated actions! doh! (they don't work in ucw for a while now and i 
forgot to send the patch (attached)).

:isolate should be used when you only want an action to fire once, even 
if the same link is clicked or the page reloaded.

For example, if i have an 'charge-credit-card' action, i would not want 
a reload of the page or a 'back-button, click same link' to charge the 
card _again_ (well, i wouldn't mind, but the customer might be pissed). 
:ISOLATE memoizes the action body so that it will only run once, 
regardless of how many times the same URL is hit.

The attached patch is against a slightly older ucw_dev. If it no longer 
applies cleanly, the replacement code for DEFACTION follows (and 
RUN-ISOLATED can be removed from standard-component.lisp).

Cheers,

drewc

(defmacro defaction (name &rest rest)
   (if (equal (car rest) :isolate)
       (with-unique-names (memo-id memo memo-present-p)
         `(defaction ,name ,(second rest)
           (let ((,memo-id
                  (strcat (mapcar (rcurry #'funcall *context*)
                                  (list #'find-session-id
                                        #'find-frame-id
                                        #'find-action-id)))))
           (multiple-value-bind (,memo ,memo-present-p)
               (gethash ,memo-id (component.isolate-hash ,(caar (second 
rest))))
             (if  ,memo-present-p
                  ,memo
                  (setf (gethash ,memo-id (component.isolate-hash ,(caar 
(second rest))))
                        (progn ,@ (cddr rest))))))))

       `(%defaction ,name , at rest)))



> 
> king regards,
> evrim.
> _______________________________________________
> bese-devel mailing list
> bese-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/bese-devel

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: isolate.patch
URL: <https://mailman.common-lisp.net/pipermail/bese-devel/attachments/20060405/e36d29d5/attachment.ksh>


More information about the bese-devel mailing list