1. cherrypy
  2. CherryPy
Issue #4 resolved

Pass virtual path as parameters

created an issue

Map the unused bits of the url into parameters of the method call.

For example, a request to the url /article/2004/09/21/01 would result in a call to the method of class Article defined as follows: {{{ def default(self, year, month, day, number): ... }}}

Query string arguments, if present, should be passed to the method as keyword arguments following the regular ones.

See [http://sourceforge.net/mailarchive/forum.php?thread_id=5611850&forum_id=13146 the original discussion].

Comments (5)

  1. sja reporter

    I had a go at implementing this... it was much too easy :-). Changing one line was enough (see attachment #4.patch).

    Better error handling is perhaps needed in the case that parameters don't match, but I didn't get too much into it because I noticed that the problem also applies to normal methods with query string parameters, and I'm not familiar with CP2's error handling mechanisms.

    I also changed tutorial 7 to make use of the new style of parameters.

  2. sja reporter

    The third patch contains bigger changes to the code designed to allow virtual path parameters to non-default methods, which I assumed would be the expected behavior.

    It also contains a fix for #2.

    I hope I didn't break anything seriously... I wish there was an automated regression test :-D.

  3. anonymous
    • The server stop routine doesn't use the port number from the configfile
    • There is no routine to verify the shutdown routine was called from localhost. This allows others to shutdown the server at will. [untested]
  4. Log in to comment