Loading Pages Automatically

9 views
Skip to first unread message

Russell Bungay

unread,
Jan 16, 2005, 5:48:29 PM1/16/05
to cherryp...@googlegroups.com
Hello all,

I am currently designing a small project that I would like to implement
in CherryPy. The ultimate end point is to have a system that displays
the scores in different categories from a trampolining competition
during that competition. I intend to have the scores displayed in a
browser displaying pages from a local CherryPy server.

I have most of the planning done. I will have a single page from which
I will import the data (in csv from the scoring program) and alter some
other minor settings. What then needs to be done is display the scores
split into the different categories.

What I have decided to do is produce multiple pages, one for each
category, and then loop through them automatically.

My specific problem relates to how I get each page to automatically load
the next page.

I could use the following in the generated html:

<META HTTP-EQUIV=REFRESH CONTENT="5;URL=http://nextpage">

and alter the URL as needed but this seems to me to be a bit of a kludge
and I was wondering if there was a specific feature in CherryPy that
would help achieve my reloading aims?

Having worked through the tutorials I did consider that I may be able to
use Aspects and _after() in particular to load the next page after a
delay. On reflection though, I don't think I can as _after() needs to
return before the original requested page is served?

I unfortunately haven't been able to think of any other ideas after
going though the tutorials and other documentation.

I do appreciate that the entire project would be more easily achieved in
a short straight-Python script, but I would like an easy project to
learn some of the ways of web applications development and in particular
CherryPy and this seemed a practical and useful way.

Thank you for your time,

Russell Bungay

Peter Hunt

unread,
Jan 16, 2005, 6:12:35 PM1/16/05
to cherryp...@googlegroups.com
Seems to me like you'd want to use JavaScript.

Scott Chapman

unread,
Jan 16, 2005, 6:52:00 PM1/16/05
to cherryp...@googlegroups.com, Russell Bungay
Russell,
Make the page establish a cookie session with the client.
Tell the page to reload itself every X seconds.
The server will use the cookie session to track which page was just sent and
knows which one to send next, sends it and updates the session info. This
can loop forever if done right.

The trick is to make the server send different content back on each refresh
depending on the session information. There are a ton of ways to accomplish
that. I'd probably make a separate function to generate each page and make
the root function call them in the right order based on the session and a
list of which ones to call in order.

Scott

Russell Bungay

unread,
Jan 18, 2005, 1:36:07 PM1/18/05
to cherryp...@googlegroups.com
Hello,

> Make the page establish a cookie session with the client.
> Tell the page to reload itself every X seconds.
> The server will use the cookie session to track which page was
> just sent and knows which one to send next, sends it and
> updates the session info. This can loop forever if done right.

Thank you for your clear answer. I was considering something along
those lines but hadn't thought about cookies. They seem to provide an
elegant solution indeed.

Russell

Russell Bungay

unread,
Jan 18, 2005, 1:37:43 PM1/18/05
to cherryp...@googlegroups.com
Peter Hunt wrote:
> Seems to me like you'd want to use JavaScript.

I did consider JavaScript that achieved something similar to the meta
tag refresh method that I mentioned but decided that would be adding
another layer of complexity especially given that I know nothing about
JavaScript.

Thank you for your help,

Russell
Reply all
Reply to author
Forward
0 new messages