[Tutor] Circular approach to a dictionary structure

Tim Johnson tim at johnsons-web.com
Sat Oct 29 00:28:12 CEST 2005

* Alan Gauld <alan.gauld at freenet.co.uk> [051028 14:05]:
> Tim,
> I don;t know if theres a better way but
> > next_phases = {"open":"review","review":"write","write":"open"}
> > 
> > Note that the value for each of the first keys is the key for
> > the next item, and that the value for the last key is the *first* key.
> But I think this is pretty neat, I like it. Now I just need to find a 
> problem that I can use it on :-)
  <blush!> Coming from you that is gratifying! 

  Here's how it manifests:
  A CGI project involving forms. 
  Forms may be either "new" or "edit", and that "mode"
    is described by the first part of the virtual document
    path (path part 1).
    path part 2 is the phase: 
      "open" => either "new" form or "edit" form filled in
                from database record 
      "review" => after posting form gives review of
                  data added or changed .
      "write" => third page, signaling successful write
                 of data to database (either update or new
                 record) and presenting
                 another URL with "open" as path part 2.

  http://www.mydomain.com/cgi-bin/script.py/new/open =>
  http://www.mydomain.com/cgi-bin/script.py/new/review =>
  http://www.mydomain.com/cgi-bin/script.py/new/write =>
  http://www.mydomain.com/cgi-bin/script.py/new/open =>


Tim Johnson <tim at johnsons-web.com>

More information about the Tutor mailing list