[Bese-devel] "Miss behavior" :action on loop

Fausto Santin fawxtin at gmail.com
Sat May 23 06:41:59 UTC 2009


Hi all,

Im updating things from ucw_dev to ucw-core, and simply got 1 hours
with a little bug bothering me. Right when I was suposed to send a help
note (this email), I found a solution to the probable bug, but Im  
still sending
this email to see/know why, and where things happened wrong.

The context: I am updating a simple blog like app, and the main render
method (that renders the list of posts) is no good at "passing actions".

;; DO NOT work ok
(defmethod render-html-body ((self lisdit))
   (<:p (<ucw:a :action (add-post self) "new post"))
   (loop :for post :in (lisdit-posts self)
      :do
      (<:div :id "lisdit-post"
	    (render post)
	    "post: " (<:as-html (lisdit-post-id post))
	    (<ucw:a :action (remove-post (lisdit-post-id post) self) "remove  
it")))) ; XXX here

Every time I use the above definition, Im getting unexpected behavior  
on the remove-post
action. Whenever remove link I click, it simply removes the most old  
item on the list. But when
I use mapcar, instead of the loop macro, Im getting what I expect,  
the remove link I click
corresponds to the expected item.

;; works OK
(defmethod render-html-body ((self lisdit))
   (<:p (<ucw:a :action (add-post self) "new post"))
   (mapcar #'(lambda (post)
	      (<:div :id "lisdit-post"
		     (render post)
		     "post: " (<:as-html (lisdit-post-id post))
		     (<ucw:a :action (remove-post (lisdit-post-id post) self)  
"remove it")))
	  (lisdit-posts self)))

Any idea why this happen?

--
Fausto LS




More information about the bese-devel mailing list