Re: URL's for multiple variable functions

Titus Brown <[email protected]>
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
-> This is a newbie question.
-> 
-> I am trying to display a query from a sql table using quixote. If I want 
-> to do a simple query it works very elegantly, for example with a simple 
-> URL:
-> 
-> http://myserver/showuserdetail/<username>
-> 
-> I can write a function for "showuserdetail" and use the _q_lookup 
-> function to access the <username> and pass it onto the SQL query
-> 
-> 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
-> 
-> and how do I write an "elegant" function to access the required 
-> variables?

Hi, Ian,

First, make the <username> page an object instead, i.e. have
'showuserdetail' use _q_lookup to load 'username' and then return a
subclass of Directory.  Then you can add _q_lookup to *that* class and
have it do the query on "November".

In your specific case, I'd almost prefer the 2nd URL hierarchy, because
it makes clear that you're talking about 'month'.  For that you can just
use request.form and iterate over the keys to construct your SQL query.

Hope that helps; let me know if you want more detail ;)

--titus
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.