ó
¤nâMc           @@  sF   d  d l  m Z d  d l m Z d  d l 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   (    (    s`   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/bazjunk/middleware/mako.pyt   __init__   s    c         C@  sÙ   y |  j  | | ƒ SWn¾ | j d d „  ƒ | ƒ s; ‚  n  t j ƒ  } | d } g  } xT | d  k	 rª | j } | j } | j | j ƒ | j j	 d ƒ rž Pn  | j
 } qZ W‚  | d d g | ƒ t j ƒ  j ƒ  g SXd  S(	   Ns   bazjunk.catch_errorsc         S@  s   t  S(   N(   t   False(   t   e(    (    s`   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/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(    (    s`   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/bazjunk/middleware/mako.pyt   __call__   s*    	
		c         c@  sÍ   | s t  ‚ n  t } y< x | D] } | Vq Wt | d ƒ rP t } | j ƒ  n  Wnu t j ƒ  j ƒ  } | rÀ t | d ƒ rÀ y | j ƒ  WqÀ |  j t	 j
 ƒ  | ƒ } | 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(    (    s`   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/bazjunk/middleware/mako.pyt   catching_iter#   s*    		(   t   __name__t
   __module__t   __doc__R   R   R'   (    (    (    s`   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/bazjunk/middleware/mako.pyR      s   		(   t
   __future__R    t   makoR   R   t   objectR   (    (    (    s`   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/bazjunk/middleware/mako.pyt   <module>   s   