Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #4 (defect)

Opened 4 years ago

Last modified 4 years ago

Pass virtual path as parameters

Status: closed (duplicate)

Reported by: sja Assigned to: hmans
Priority: normal Milestone: 2.0-alpha
Component: CherryPy code Keywords:
Cc: cherrypy@attardi.org

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 the original discussion.

Attachments

#4.patch (1.6 kB) - added by sja on 09/25/04 13:24:43.
Patch for #4
#4b.patch (1.6 kB) - added by sja on 09/25/04 20:48:29.
This one works better since it doesn't rely on cpg.request.virtualPath which is computed incorrectly
#2-#4.patch (4.1 kB) - added by sja on 09/25/04 20:56:57.
More aggressive changes
#2-#4b.patch (8.2 kB) - added by sja on 09/26/04 10:03:28.
Like the previous one, plus an implementation of the latest idea for #2, an updated test.py, and a couple of tiny fixes
#2-#4c.patch (8.4 kB) - added by sja on 09/26/04 21:53:06.
Same as the previous, plus special behavior for methods defined with no parameters

Change History

09/25/04 13:24:43: Modified by sja

  • attachment #4.patch added.

Patch for #4

09/25/04 13:32:35: Modified by sja

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.

09/25/04 20:48:29: Modified by sja

  • attachment #4b.patch added.

This one works better since it doesn't rely on cpg.request.virtualPath which is computed incorrectly

09/25/04 20:56:57: Modified by sja

  • attachment #2-#4.patch added.

More aggressive changes

09/25/04 20:59:26: Modified by sja

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.

09/26/04 10:03:28: Modified by sja

  • attachment #2-#4b.patch added.

Like the previous one, plus an implementation of the latest idea for #2, an updated test.py, and a couple of tiny fixes

09/26/04 21:53:06: Modified by sja

  • attachment #2-#4c.patch added.

Same as the previous, plus special behavior for methods defined with no parameters

11/07/04 08:25:28: Modified by rdelon

  • status changed from new to closed.
  • resolution set to duplicate.

The new findItem function from Carlos handles this

12/13/04 02:50:20: Modified by 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]

Hosted by WebFaction

Log in as guest/cpguest to create tickets