[Bese-devel] Re: Another newbie UCW question.. dynamic links

Marco Baringer mb at bese.it
Fri Jun 16 08:11:34 UTC 2006


Dan Beauchesne <dbeauchesne at gmail.com> writes:

> Hi list,
>
> Thanks to Lou I got UCW working. But I've already hit a snag. 
>
> Basically, I want to query the user and search through a hash table
> for results, and then display the results. That part works fine. 
>
> The thing is, I need each separate result to be a link which, when
> clicked, will add that result to a separate list.
>
> I did something like.. (in the main component)
>
> (dotimes (n (length results))
   ^^^^^^^

(this may not be your only problem). DOTIMES is not required, by ansi,
to create a new binding for the iteration variable (n in this case) on
each iteration of the loop. the :action attribute which you have on
the next line creates a lambda which clases over the binding of N, if
DOTIMES reuses the same bindings then all links will end up doing the
same thing (call add-to-list with n bound to (length results) or NIL
depending). what you want is the dolist* macro (part of arnesi) which
ensures that a fresh binding is created:

(dolist* (n (length results))
  (ucw-stuff-goas-here))

> (ucw:a :action (add-to-list main (nth n results))
> (<:as-html (nth n results))))
>
> (defaction add-to-list ((res main) it)
>   (setf (clicked-list main) (append (list it) (clicked-list main))))
>
> I thought this was too easy, and apparently it was :), the page loads
> fine and each result it clickable, but when I click it, some kind of
> inifinite loop happens (doesn't say what), and I have to kill it. 

if you wait long enough you will eventually get a stack-overflow, that
will be accompanied by a backtrace which we can then use to figure
where the infinite loop is happening. (btw: the ucw error includes a
backtrace, the backtrace includes copies of all the data on the stack
_copied_ for each frame. i once had an error in a file uploead page,
in the error page the file's contents (17+MB pdf) was being displayed
about 20 times, it took about 5 minutes to show the page. unless
you're getting a stack-overflow error don't be sure that it's an
infinite loop error).

-- 
-Marco
Ring the bells that still can ring.
Forget your perfect offering.
There is a crack in everything.
That's how the light gets in.
	-Leonard Cohen




More information about the bese-devel mailing list