Ñò
$fLc           @   sM  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 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  d k Z d  d k  Z  d  d k! Z! d* Z" d e# f d „  ƒ  YZ$ d „  Z% d „  Z& e e& ƒ Z& d „  Z' e e' ƒ Z' d „  Z( e e( ƒ Z( d „  Z) e e) ƒ Z) d „  Z* e e* ƒ Z* d „  Z+ e e+ ƒ Z+ d „  Z, e e, ƒ Z, d „  Z- e e- ƒ Z- d  „  Z. e e. ƒ Z. d! „  Z/ d" „  Z0 d# „  Z1 d$ „  Z2 d% d& „ Z3 e! i4 d' ƒ Z5 e! i4 d( ƒ Z6 d) „  Z7 d S(+   iÿÿÿÿ(   t   templatet   templatetags(   t   RequestContext(   t   settings(   t   staff_member_required(   t   models(   t   render_to_response(   t   ImproperlyConfiguredt   ViewDoesNotExist(   t   Http404(   t   urlresolvers(   t   utils(   t   Site(   t   import_module(   t   ugettext(   t	   mark_safeNt   _t   add_t   deletet   savet   set_t   GenericSitec           B   s   e  Z d  Z d Z RS(   s   example.coms   my site(   t   __name__t
   __module__t   domaint   name(    (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyR      s   c          C   s„   y t  i d ƒ SWnl t  i j
 o] d d k l }  y  t  i |  i i d d g ƒSWq€ t  i j
 o t t d d ƒ SXn Xd  S(   Ns   admin:indexiÿÿÿÿ(   t   admint   argst    t   ADMIN_SITE_ROOT_URLs   /admin/(	   R
   t   reverset   NoReverseMatcht   django.contribR   t   sitet   roott   getattrR   (   R   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyt   get_root_path   s     c         C   s8   t  i p t |  ƒ St d h t ƒ  d 6d t |  ƒ ƒS(   Ns   admin_doc/index.htmlt	   root_patht   context_instance(   R   t   docutils_is_availablet   missing_docutils_pageR   R$   R   (   t   request(    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyt	   doc_index"   s
    
	c         C   s]   t  ƒ  } t d h | d 6t d |  i ƒ  o d p d |  i ƒ  | f ƒ d 6d t |  ƒ ƒS(   Ns   admin_doc/bookmarklets.htmlR%   s	   %s://%s%st   httpst   httpt	   admin_urlR&   (   R$   R   R   t	   is_securet   get_hostR   (   R)   t
   admin_root(    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyt   bookmarklets*   s
    		7c      
   C   sÄ  t  i p t |  ƒ St ƒ  g  } t i i ƒ  } g  } t i D] } | d  | f q? ~ } x<| | D]0\ } } x!| i	 i ƒ  D]\ } }	 t  i
 |	 i ƒ \ }
 } } |
 o# t  i |
 d t d ƒ | ƒ }
 n | o# t  i | d t d ƒ | ƒ } n x5 | D]- } t  i | | d t d ƒ | ƒ | | <qW| t i j o
 d  } n | i d ƒ d } | i h | d 6|
 d 6| d 6| d 6| d	 6ƒ q‚ Wqf Wt d
 h t ƒ  d 6| d 6d t |  ƒ ƒS(   Nt   tags   tag:t   .iÿÿÿÿR   t   titlet   bodyt   metat   librarys!   admin_doc/template_tag_index.htmlR%   t   tagsR&   (   R   R'   R(   t%   load_all_installed_template_librariesR    t	   librariest   itemst   builtinst   NoneR8   t   parse_docstringt   __doc__t	   parse_rstR   t   splitt   appendR   R$   R   (   R)   R8   t   app_libst   _[1]t   libt   builtin_libst   module_nameR7   t   tag_namet   tag_funcR4   R5   t   metadatat   keyt   tag_library(    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyt   template_tag_index2   s>    
*  ## +
		

c      
   C   sÄ  t  i p t |  ƒ St ƒ  g  } t i i ƒ  } g  } t i D] } | d  | f q? ~ } x<| | D]0\ } } x!| i	 i ƒ  D]\ } }	 t  i
 |	 i ƒ \ }
 } } |
 o# t  i |
 d t d ƒ | ƒ }
 n | o# t  i | d t d ƒ | ƒ } n x5 | D]- } t  i | | d t d ƒ | ƒ | | <qW| t i j o
 d  } n | i d ƒ d } | i h | d 6|
 d 6| d 6| d 6| d	 6ƒ q‚ Wqf Wt d
 h t ƒ  d 6| d 6d t |  ƒ ƒS(   Nt   filters   filter:R3   iÿÿÿÿR   R4   R5   R6   R7   s$   admin_doc/template_filter_index.htmlR%   t   filtersR&   (   R   R'   R(   R9   R    R:   R;   R<   R=   RO   R>   R?   R@   R   RA   RB   R   R$   R   (   R)   RO   RC   RD   RE   RF   RG   R7   t   filter_namet   filter_funcR4   R5   RJ   RK   RL   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyt   template_filter_indexU   s>    
*  ## +
		

c      
   C   sL  t  i p t |  ƒ St i o. g  } t i D] } | t | ƒ q- ~ } n
 t g } g  } xÃ | D]» } t | i ƒ } t | i ƒ } t	 i
 i o t	 i i d | i ƒ } n
 t ƒ  } xb | D]Z \ }	 }
 | i h t |	 d |	 i i ƒ d 6|	 i d 6| i d 6| d 6t |
 ƒ d 6ƒ qÀ Wqc Wt d h t ƒ  d	 6| d
 6d t |  ƒ ƒS(   Nt   pkR   R   t   modulet   site_idR!   t   urls   admin_doc/view_index.htmlR%   t   viewsR&   (   R   R'   R(   R   t	   ADMIN_FORR   t   ROOT_URLCONFt   extract_views_from_urlpatternst   urlpatternsR   t   _metat	   installedt   objectst   gett   SITE_IDR   RB   R#   t	   __class__R   R   t   simplify_regexR   R$   R   (   R)   RD   t   mt   settings_modulesRW   t   settings_modt   urlconft   view_functionst   site_objt   funct   regex(    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyt
   view_indexx   s2    

.	 	 	

	

c   	      C   sK  t  i p t |  ƒ St i | ƒ \ } } y t t | ƒ | ƒ } Wn t t f j
 o t	 ‚ n Xt  i
 | i ƒ \ } } } | o# t  i | d t d ƒ | ƒ } n | o# t  i | d t d ƒ | ƒ } n x5 | D]- } t  i | | d t d ƒ | ƒ | | <qÛ Wt d h t ƒ  d 6| d 6| d 6| d 6| d	 6d
 t |  ƒ ƒS(   Nt   views   view:t   models   admin_doc/view_detail.htmlR%   R   t   summaryR5   R6   R&   (   R   R'   R(   R
   t   get_mod_funcR#   R   t   ImportErrort   AttributeErrorR	   R>   R?   R@   R   R   R$   R   (	   R)   Rl   t   modRi   t	   view_funcR4   R5   RJ   RK   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyt   view_detail—   s,    
## +	

c         C   si   t  i p t |  ƒ Sg  } t i ƒ  D] } | | i q& ~ } t d h t ƒ  d 6| d 6d t |  ƒ ƒS(   Ns   admin_doc/model_index.htmlR%   R   R&   (	   R   R'   R(   R   t
   get_modelsR\   R   R$   R   (   R)   RD   Rc   t   m_list(    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyt   model_index°   s    
*	

c         C   sí  t  i p t |  ƒ Sy t i | ƒ } Wn) t j
 o t t d ƒ | ƒ ‚ n Xd  } x; t i	 | ƒ D]* } | i
 i i ƒ  | j o | } Pqj qj W| d  j o( t t d ƒ h | d 6| d 6ƒ ‚ n | i
 } g  } xÈ | i D]½ } t | t i ƒ o` | i i i }	 }
 | i i i
 i } t  i t d ƒ h | d 6|	 d 6d t d ƒ |	 ƒ } n t | ƒ }	 | i } | i h | i d	 6|	 d 6| d
 6| i d 6ƒ qæ Wxò | i D]ç } | i i i }	 }
 | i i i
 i } t d ƒ h | d 6|	 d 6} | i h d | i d	 6d d 6t  i t d ƒ | d t d ƒ | i ƒ d
 6ƒ | i h d | i d	 6d d 6t  i t d ƒ | d t d ƒ | i ƒ d
 6ƒ q±Wx | i i ƒ  D]ï \ } } t i | ƒ oÓ t  t i! | ƒ d ƒ d j o³ y/ x( t" D]  } | i# | ƒ o
 t$ ‚ qòqòWWn t$ j
 o
 q¬n X| i% } | o/ t  i t  i& | ƒ d t d ƒ | i ƒ } n | i h | d	 6t' | ƒ d 6| d
 6ƒ q¬q¬Wxì | i( ƒ  | i) ƒ  D]Ô } t d ƒ h | i* i d 6| i* i d 6} | i+ ƒ  } | i h d | d	 6d d 6t  i t d ƒ | d t d ƒ | i ƒ d
 6ƒ | i h d | d	 6d d 6t  i t d ƒ | d t d ƒ | i ƒ d
 6ƒ q¶Wt, d h t- ƒ  d 6d | i | i f d	 6t d ƒ | i d 6| i% d 6| d 6d t. |  ƒ ƒS(   Ns   App %r not founds3   Model %(model_name)r not found in app %(app_label)rt
   model_namet	   app_labels0   the related `%(app_label)s.%(data_type)s` objectt	   data_typeRm   s   model:R   t   verboset	   help_texts/   related `%(app_label)s.%(object_name)s` objectst   object_names   %s.allt   Lists   all %ss   %s.countt   Integers   number of %si    i   s   admin_doc/model_detail.htmlR%   s   %s.%ss   Fields on %s objectsRn   t   descriptiont   fieldsR&   (/   R   R'   R(   R   t   get_appR   R	   R   R=   Ru   R\   R}   t   lowerR   t
   isinstancet
   ForeignKeyt   relt   toR   Ry   R@   t   get_readable_field_data_typet   verbose_nameRB   R   R|   t   many_to_manyRG   t   __dict__R;   t   inspectt
   isfunctiont   lent
   getargspect   MODEL_METHODS_EXCLUDEt
   startswitht   StopIterationR?   t   trim_docstringt   get_return_data_typet   get_all_related_objectst$   get_all_related_many_to_many_objectst   optst   get_accessor_nameR   R$   R   (   R)   Ry   Rx   t   app_modRm   Rc   R—   R   t   fieldRz   t   related_object_nameR{   t	   func_nameRi   t   excludeR†   t   accessor(    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyt   model_detailº   sœ    
 	(	
 ;		

 	1	5 0 	/	 *	1	5	


c            s  g  } xÙ t  i D]Î } t | ƒ } t i i o t i i d | i ƒ } n
 t	 ƒ  } x‡ | i
 D]| } t i i | | ƒ ‰  | i h ˆ  d 6t i i ˆ  ƒ d 6‡  f d †  d 6| i d 6| d 6t | i
 ƒ i | ƒ d 6ƒ q^ Wq Wt d	 h t ƒ  d
 6| d 6| d 6d t |  ƒ ƒS(   NRS   t   filet   existsc              s*   t  i i ˆ  ƒ o t ˆ  ƒ i ƒ  p d  S(   R   (   t   ost   pathR¡   t   opent   read(    (   t   template_file(    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyt   <lambda>&  s    t   contentsRU   R!   t   orders   admin_doc/template_detail.htmlR%   R   t	   templatesR&   (   R   RX   R   R   R\   R]   R^   R_   R`   R   t   TEMPLATE_DIRSR¢   R£   t   joinRB   R¡   t   listt   indexR   R$   R   (   R)   R    Rª   t   site_settings_moduleRe   Rh   t   dir(    (   R¦   sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyt   template_detail  s,    
 	
 	
%	

c         C   s
   t  d ƒ S(   s4   Display an error message for people without docutilss   admin_doc/missing_docutils.html(   R   (   R)   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyR(   6  s    c       	   C   sÔ   xÍ t  i ƒ  D]¿ }  t |  ƒ } g  } t i t i i | i ƒ ƒ D]B } | i d ƒ o, | d i	 ƒ  o | t i i
 | ƒ d qB qB ~ } x< | D]4 } y t  i | ƒ } Wq” t  i j
 o	 } q” Xq” Wq Wd  S(   Ns   .pyi    (   R    t   get_templatetags_modulesR   R¢   t   listdirR£   t   dirnamet   __file__t   endswitht   isalphat   splitextt   get_libraryt   InvalidTemplateLibrary(   RG   Rr   RD   t   pR:   t   library_nameRE   t   e(    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyR9   :  s     "E c         C   sB   |  i  d ƒ o. |  i d ƒ o d S|  i d ƒ o d Sn d S(   s9   Return a somewhat-helpful data type given a function namet   get_t   _listR~   t   _countR   R   (   R‘   R¶   (   Rœ   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyR”   I  s    	c         C   s   |  i  |  i S(   sË   Returns the description for a given field type, if it exists,
    Fields' descriptions can contain format strings, which will be interpolated
    against the values of field.__dict__ before being output.(   R€   R‹   (   Rš   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyRˆ   R  s    R   c      	   C   sß   g  } xÒ |  D]Ê } t  | d ƒ oD y' | i | i ƒ  | | i i f ƒ Wq× t j
 o
 q q× Xq t  | d ƒ oJ y | i } Wn t j
 o
 q n X| i t	 | | | i i ƒ ƒ q t
 t d ƒ | ƒ ‚ q W| S(   s…   
    Return a list of views from a list of urlpatterns.

    Each object in the returned list is a two-tuple: (view_func, regex)
    t   _get_callbackt   _get_url_patternss,   %s does not appear to be a urlpattern object(   t   hasattrRB   RÁ   Rj   t   patternR   t   url_patternsRp   t   extendRZ   t	   TypeErrorR   (   R[   t   baseRW   R»   t   patterns(    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyRZ   Y  s      '$s   \(\?P(<\w+>).+?\)s   \(.*?\)c         C   s‹   t  i d „  |  ƒ }  t i d |  ƒ }  |  i d d ƒ i d d ƒ i d d ƒ i d d ƒ i d	 d ƒ }  |  i d ƒ p d |  }  n |  S(
   sØ   
    Clean up urlpattern regexes into something somewhat readable by Mere Humans:
    turns something like "^(?P<sport_slug>\w+)/athletes/(?P<athlete_slug>\w+)/$"
    into "<sport_slug>/athletes/<athlete_slug>/"
    c         S   s   |  i  d  ƒ S(   i   (   t   group(   Rc   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyR§   z  s    s   <var>t   ^R   t   $t   ?s   //t   /s   \(   t   named_group_matchert   subt   non_named_group_matchert   replaceR‘   (   RÄ   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyRb   s  s    B(   R   R   R   R   s   set_(8   t   djangoR    R   t   django.templateR   t   django.confR   t%   django.contrib.admin.views.decoratorsR   t	   django.dbR   t   django.shortcutsR   t   django.core.exceptionsR   R   t   django.httpR	   t   django.coreR
   t   django.contrib.admindocsR   t   django.contrib.sites.modelsR   t   django.utils.importlibR   t   django.utils.translationR   R   t   django.utils.safestringR   RŒ   R¢   t   reR   t   objectR   R$   R*   R1   RM   RR   Rk   Rt   Rw   RŸ   R±   R(   R9   R”   Rˆ   RZ   t   compileRÏ   RÑ   Rb   (    (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/admindocs/views.pyt   <module>   sV   $	
			!	!				]						