Re: URI Templates - optional variables? (explain.cgi)

On Wed, 2007-10-17 at 21:17 -0400, Joe Gregorio wrote:
> On 10/17/07, Dan Connolly <connolly@w3.org> wrote:
> > spiffy.
> >
> > I'd like to look at the source. I looked around and couldn't
> > find it. Is it world-readable?
> 
> My bad, I didn't check it into subversion. It's now been
> added to the uri-templates project.

OK, found it.
http://uri-templates.googlecode.com/svn/trunk/explain.cgi

>  It's about 80 lines
> of pretty sloppy Python code, so you've been warned :)

Yeah... looks like perl code. ;-)

OK... as an exercise in understanding the code, I
made the main body into a function, factored
out 3 parts, and added doctests. Enjoy.

While I was at it, I think I fixed a bug: in
the case of "Not a valid URI Template", I think
your code gives an HTTP 200 and then prints
an HTTP 400 status message in the body.

You might add a clue about how to satisfy 'import tpg'
in template_parser.py; tpg isn't in apt nor the CheeseShop,
so I had to hunt for it a bit.
http://christophe.delord.free.fr/tpg/index.html

I made an hg clone of the SVN project with hgimportsvn first,
just for fun our out of habit or whatever...

http://homer.w3.org/~connolly/projects/uri-templates/
6:3609c0d2de5f 2007-10-17 factored cgi handler into 3 parts with
doctests
5:dfb20fe77f99 2007-10-17 move CGI routine to a function; add --test
command-line option


-- 
Dan Connolly, W3C http://www.w3.org/People/Connolly/
gpg D3C2 887B 0F92 6005 C541  0875 0F91 96DE 6E52 C29E

Received on Thursday, 18 October 2007 04:45:55 UTC