[ZPT] request['traverse_subpath']

Jules jules@jules.com
Fri, 7 Dec 2001 10:25:07 -0500


One of the great things about Zope is being able to construct "nice"
URLs (or URLs you Mum can remember according to Zope Corp's Rob Page!).
And ZPT is no exception. One can say

	/some/path/zpt_file/sub_path_item

Where zpt_file is the page template and sub_path_item is some arbitrary
goodie that means something to the ZPT template. It's not a zope
object, it's like QUERY_STRING on other Web platforms.

However, with ZPT, if it's /not/ there, it raises an exception. Try it
and then try sniffing for it. Bang!

To get around this, I ended up writing a Q&D Python script which takes
traverse_subpath and the position as args.

	<span tal:define="global zero
	python:here.ro(request['traverse_subpath'],0) ... >

And the script looks like this:

	try:
		return thingie[int(element)]
	except IndexError:
		return None

Now what would be a great enhancement is request/traverse_subpath/0,
request/traverse_subpath/1, etc.

Or am I just going about this the wrong way?

Thanks!
Jules

-- 
"You should never wear your best trousers when you go out to fight for
 freedom and liberty." -- Henrik Ibsen