Currently, if Quixote goes looking for _q_index() in some namespace and
fails to find it, it dies with an ImportError. That's kind of silly --
it's quite reasonable for a namespace not to provide an index function.
(By analogy, not every directory in a static-file website has an
index.html function, and if you've disabled Apache's automatic index
generation, you get an HTTP 403 "Access denied" error -- not a 500
"Internal server error"!)
The patch below fixes the problem by turning the ImportError into a
Quixote AccessError, which eventually becomes an HTTP 403. (I don't
think 404 is appropriate here: if "/user/tim" and "/user/bob" exist,
then so does "/user/" -- but if you choose not to implement _q_index()
for that namespace, you're denying access to part of your URL-space to
the entire world.)
--- publish.py (revision 21034)
+++ publish.py (working copy)
@@ -554,8 +554,15 @@
for component in path_components:
if component == "":
# "/q/foo/" == "/q/foo/_q_index"
- component = "_q_index"
- object = self.get_component(object, component, path, request)
+ try:
+ object = self.get_component(object, "_q_index",
+ path, request)
+ except ImportError, err:
+ raise errors.AccessError(
+ public_msg="no index for this folder",
+ private_msg="Import error: %s" % err)
+ else:
+ object = self.get_component(object, component, path, request)
if not (isstring(object) or callable(object)):
# We went through all the components of the path and ended up at
I think this should probably wait until Quixote 0.6 is released, as it
meddles right in the core of Quixote. I can live with my ImportError
traceback for a while longer. Opinions?
Greg