Ñò
3Nc           @@  sF   d  d k  l Z d  d k l Z d  d k Z d e f d „  ƒ  YZ d S(   i    (   t   absolute_import(   t
   exceptionsNt   CatchMakoErrorsc           B@  s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s6   Use Mako's error reporting faculties when appropriate.c         C@  s   | |  _  d  S(   N(   t   app(   t   selfR   (    (    sG   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazjunk/middleware/mako.pyt   __init__   s    c         C@  sß   y |  i  | | ƒ SWnÄ | i d d „  ƒ | ƒ p ‚  n t i ƒ  } | d } g  } xX | d  j	 oG | i } | i } | i | i ƒ | i i	 d ƒ o Pn | i
 } q\ W‚  | d d g | ƒ t i ƒ  i ƒ  g SXd  S(	   Ns   bazjunk.catch_errorsc         S@  s   t  S(    (   t   False(   t   e(    (    sG   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazjunk/middleware/mako.pyt   <lambda>   s    i   t   _maks   500 Internal Server Errors   content-types	   text/html(   s   content-types	   text/html(   R   t   gett   syst   exc_infot   Nonet   tb_framet   f_codet   appendt   co_filenamet   endswitht   tb_nextR   t   html_error_templatet   render(   R   t   environt   start_responseR   t   tbt   lstt   framet   code(    (    sG   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazjunk/middleware/mako.pyt   __call__   s,    	
 		c         c@  sÔ   | p
 t  ‚ n t } y> x | D] } | Vq! Wt | d ƒ o t } | i ƒ  n Wnx t i ƒ  i ƒ  } | oR t | d ƒ oB y | i ƒ  WqÇ |  i t	 i
 ƒ  | ƒ } | d | 7} qÇ Xn | Vn Xd  S(   Nt   closes$   <hr noshade>Error in .close():<br>%s(   t   StopIterationR   t   hasattrt   TrueR   R   R   R   t   exception_handlerR   R   (   R   t   app_iterR   t   error_on_closet   vt   responset   close_response(    (    sG   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazjunk/middleware/mako.pyt   catching_iter#   s,    
 	(   t   __name__t
   __module__t   __doc__R   R   R'   (    (    (    sG   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazjunk/middleware/mako.pyR      s   		(   t
   __future__R    t   makoR   R   t   objectR   (    (    (    sG   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazjunk/middleware/mako.pyt   <module>   s   