[contestms] Re: Support for running from URLs other than /

  • From: Bernard Blackham <bernard@xxxxxxxxxxxxxxxx>
  • To: contestms@xxxxxxxxxxxxx
  • Date: Mon, 12 Mar 2012 18:45:24 +0000

On 12/03/2012, at 4:17 PM, Giovanni Mascellani wrote:
> On 12/03/2012 15:33, Bernard Blackham wrote:
>> I saw two options for doing this:
>> 
>> (1) make all URLs generated by CWS/AWS relative. This would allow you
>> to simply map http://myserver/contest/ioi2012/ ->
>> http://localhost:8888/ And CWS/AWS does not need to know about the
>> extra url prefix.
> 
> I also agree that (1) is hardly feasible: to implement it you should
> probably filter each URL through a function that detects the nesting
> level of the calling page and add a proper number of ".." in front of
> the URL. I don't like it, it seems to be quite weak.

Actually I found a neat way to do it just by counting '/' chars in 
self.request.uri and it seems reasonably reliable.

https://github.com/bblackham/cms/commit/2d454124ded8a2bed197ff895d318e58f6de3a11

This commit is rebased against master (ditching the old one). It
 - puts spaces around {{ x }} in the templates
 - barely touches the python sources
 - generates completely relative URLs!
 - (and thus keeps the url_root out of the configuration)

I've done a moderate amount of manual testing. It would be cool to have a 
version of Irene that exhaustively follows every link accessible on the contest 
and admin websites. Another day :)

Cheers,
Bernard.


Other related posts: