Ñò
É•©Lc           @   sÈ   d  d k  Z  d  d k Z d  d k l Z d  d k l Z l Z d  d k l Z d  d k l	 Z	 d  d k
 l Z d  d k l Z d  d k l Z d  d	 k l Z d  d
 k l Z d e f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   PermissionDenied(   t   HttpResponseForbiddent   HttpResponseServerError(   t   Http404(   t   render_to_string(   t   RequestContext(   t   ugettext(   t   settings(   t   mail_admins(   t   lt   ErrorPagesMiddlewarec           B   s   e  Z d  Z d „  Z RS(   s    
    Friendlier Error Pages
    c   	      C   sû  t  | t ƒ o nät  | t ƒ o‡ h  } t | i ƒ d j o t | ƒ | d <n | i i ƒ  p* t d h t	 d ƒ d 6ƒ } | | d <n t
 t d | t | ƒ ƒ ƒ St i ƒ  } t i | IJt i p)yh  } t | i ƒ d j o t | i d ƒ | d <n t | d	 ƒ o+ t d
 h | i d	 6| i d 6ƒ | d <n d | i i d ƒ t i j o d p d | i f } y t | ƒ } Wn d } n Xd t | i d ƒ | | f } t | | d t ƒt t d | t | ƒ ƒ ƒ SWq÷q÷Xn d  S(   Ni    t   permission_errorsC   You need to <a href="%(login_link)s">login</a> to access this page.s   /accounts/login/t
   login_linkt   login_messages   403.htmlt	   exceptiont   filenamesA   Error accessing %(filename)s, Filesystem sent error: %(errormsg)st   errormsgt   fserrors   Error (%s IP): %st   REMOTE_ADDRt   internalt   EXTERNALs   Request repr() unavailables
   %s

%s

%st   fail_silentlys   500.html(   t
   isinstanceR   R    t   lent   argst   unicodet   usert   is_authenticatedt   _R	   R   R   R   t	   tracebackt
   format_exct   syst   stderrR   t   DEBUGt   hasattrR   t   strerrort   METAt   gett   INTERNAL_IPSt   patht   reprR   t   TrueR   (	   t   selft   requestR   t   templatevarst	   login_msgt   tbt   subjectt   request_reprt   message(    (    s?   /var/www/Pootle/local_apps/pootle_misc/middleware/errorpages.pyt   process_exception'   sB    
%6
 (   t   __name__t
   __module__t   __doc__R2   (    (    (    s?   /var/www/Pootle/local_apps/pootle_misc/middleware/errorpages.pyR
   #   s   (   R   R   t   django.core.exceptionsR    t   django.httpR   R   R   t   django.template.loaderR   t   django.templateR   t   django.utils.translationR   R   t   django.confR   t   django.core.mailR   t   pootle_misc.baseurlR	   t   objectR
   (    (    (    s?   /var/www/Pootle/local_apps/pootle_misc/middleware/errorpages.pyt   <module>   s   