durusmail: quixote-users: Handling lack of _q_index()
Handling lack of _q_index()
2003-03-12
2003-03-12
2003-03-12
Handling lack of _q_index()
Andrew Kuchling
2003-03-12
On Wed, Mar 12, 2003 at 10:42:14AM -0500, Greg Ward wrote:
>The patch below fixes the problem by turning the ImportError into a
>Quixote AccessError, which eventually becomes an HTTP 403.  (I don't

Catching an ImportError exception is a bit unsettling.  How about this
simpler patch to get_component?

Index: publish.py
===================================================================
*** publish.py  (revision 21077)
--- publish.py  (working copy)
***************
*** 469,480 ****
--- 469,484 ----
          # From here on, you can assume that the name is either in
          # _q_exports, or the name is '_q_index'
          elif hasattr(container, component):
              # attribute is in _q_exports and exists
              object = getattr(container, component)

+         elif component == '_q_index':
+             raise errors.AccessError(
+                 private_msg=("_q_index not found in %r" % container))
+
          elif hasattr(container, "_q_resolve"):
              object = container._q_resolve(component)
              if object is None:
                  raise RuntimeError, ("component %r listed in _q_exports, "
                                       "but not returned by _q_resolve()"
                                       % component)

Possibly the "component == '_q_index'" should come after trying
_q_resolve.

>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?

I'd be happy with releasing 0.6b4 with the above change, and then
calling it 0.6final after another week of further testing.

--amk                                                    (www.amk.ca)
EDMUND: Know thou this, that men are as the time is.
      -- _King Lear_, V, iii

reply