Re: URL's for multiple variable functions

Michael Watkins <[email protected]>
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
* Ian Forbes wrote [2005-11-17 17:29:24 +0200]:
 
> But suppose I want user statistics for the month of November. What do I 
> use for a URL:
> 
> http://myserver/showuserstatistics/<username>/November
> or
> http://myserver/showuserstatistics/<username>?month=November

A more detailed reply I had all cooked up got trashed by a system panic (darn
you, Western Digital), so in a nutshell the second time around:

I'd probably change your url around a little, since its about users and
you'll no doubt have other user-specific UI needs:

    http://myserver/myaccount/
    or..
    http://myserver/my/

Where 'my' is a representation of your user fulfilled by a UserUI object
of your design, exporting a number of methods so you can hang off this...

    http://myserver/my/change
    http://myserver/my/change_password
    http://myserver/my/suspend_subscription
    http://myserver/my/statistics/

.... and statistics will call a StatisticsUI object

    class UserUI:

        ...
        def statistics(self):
            return StatisticsUI(self.user)._q_index()

Which may present a list of available statistics links, or the current (or
just past) month and then links to older records.

    and your stats detail page(s):

    http://myserver/my/statistics/November
    or
    http://myserver/my/statistics/11

    will be returned from a _q_lookup(self, component) method.

But... assuming your site will live on for years, you probably also want to
support urls like this:
    
    http://myserver/my/statistics/2005/11

By the time you are down to the year/month component(s) of your URL, assuming
there's no expected future need for more detail, you could stop traversing
the path using subsequent calls to _q_lookup. In other words, once you have

    2005
    
    or

    2005/11

.... you have what you need to be able to deliver the right response.

You'll find a discussion of this in the archives back in July - follow this
thread: 

http://mail.mems-exchange.org/pipermail/quixote-users/2005-July/045592.html

And perhaps also look at:

http://mail.mems-exchange.org/pipermail/quixote-users/2005-July/049953.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.