in reply to Mason: Please Wait While Generating

I do something similar to what you are asking using mason's cache as a flag to say it's being built.
my $page = $m->dhandler_arg; # do sanity checking ... unless ($m->comp_exists($page)) { unless ($m->cache->get($page)) { # see if we're building it already $m->cache->set($page,'1','60 sec'); # set a flag to say we're buil +ding it $m->comp("/building_page"); # please wait page $m->flush_buffer; # flush the output # here we begin building the page $m->comp("/build_page", $page); } $m->comp("/building_page"); $m->flush_buffer; } </%init>

The building page, would spit up a simple note saying it's processing, and a meta-refresh tag so the client re-requests it in a moment. A little css/javascript can be used to add some animation to keep them amused.

(code above is untested, but should get you going in the right direction)

Replies are listed 'Best First'.
Re^2: Mason: Please Wait While Generating
by water (Deacon) on Jul 20, 2005 at 21:45 UTC
    Thanks, cowboy, this looks great.

    I don't follow all of it, though.

    Is there an automatic redirect to the finished page? Or is the user just instructed to hit refresh after waiting a bit on the building_page component?

    thanks

    water

      I basically print out a very light 'Loading' type page, which has a meta-refresh tag to tell the client to re-request it in a few seconds.

      If it has completed whatever work it needs to do (in my case, execute a heavy database query and collect results, then cache them), it then displays the results (which are now in the cache), if it hasn't completed it, it spits up the 'Loading' page again, set to refresh again.

      (update:) The basic logic is as follows:
      if (page_is_in_cache) { display page. } elsif (flag_is_in_cache) { page is being rendered, display a 'loading' message with a meta refr +esh } else { set_flag_in_cache display loading page render page stuff page in cache clear flag in cache }