Ńň
şú˛Hc           @   s  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 e
 f d	     YZ d
 e f d     YZ d e f d     YZ d e f d     YZ e   Z d  d k l Z d  d k l Z d  d k l Z d e f d     YZ d S(   i˙˙˙˙(   t   http(   t   models(   t	   EasyModel(   t   render_to_response(   t	   mark_safet   AlreadyRegisteredc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyR      s   t   NotRegisteredc           B   s   e  Z RS(    (   R   R   (    (    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyR   
   s   t   DatabrowsePluginc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s   d S(   s  
        Given an EasyInstanceField object, returns a list of URLs for this
        plugin's views of this object. These URLs should be absolute.

        Returns None if the EasyInstanceField object doesn't get a
        list of plugin-specific URLs.
        N(   t   None(   t   selft   plugin_namet   easy_instance_field(    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyt   urls   s    c         C   s   d S(   sO   
        Returns a snippet of HTML to include on the model index page.
        t    (    (   R   t   requestt   modelt   site(    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyt   model_index_html   s    c         C   s
   t   d S(   sO   
        Handles main URL routing for a plugin's model-specific pages.
        N(   t   NotImplementedError(   R   R   t   model_databrowset   url(    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyt
   model_view   s    (   R   R   R   R   R   (    (    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyR	      s   	
	t   ModelDatabrowsec           B   s)   e  Z h  Z d    Z d   Z d   Z RS(   c         C   s   | |  _  | |  _ d  S(   N(   R   R   (   R   R   R   (    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyt   __init__'   s    	c      
   C   sŁ   | d j o |  i |  Sy | i d d  \ } } Wn  t j
 o | d } } n Xy |  i | } Wn" t j
 o t i d   n X| i | |  |  S(   s   
        Handles main URL routing for the databrowse app.

        `url` is the remainder of the URL -- e.g. 'objects/3'.
        t   /i   s0   A plugin with the requested name does not exist.N(	   R
   t	   main_viewt   splitt
   ValueErrort   pluginst   KeyErrorR    t   Http404R   (   R   R   R   R   t   rest_of_urlt   plugin(    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyt   root+   s    c      	   C   s   t  |  i |  i  } t d i g  } |  i i   D]" } | | i | |  i |  i  q2 ~   } t d h | d 6|  i i	 d 6| d 6 S(   Nu   
s   databrowse/model_detail.htmlR   t   root_urlt   plugin_html(
   R   R   R   R   t   joinR   t   valuesR   R   R$   (   R   R   t
   easy_modelt   _[1]t   pt   html_snippets(    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyR   >   s    N	(   R   R   R   R   R#   R   (    (    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyR   $   s   		t   DatabrowseSitec           B   sD   e  Z d    Z d d  Z d   Z d   Z d   Z d d  Z RS(   c         C   s   h  |  _  d  |  _ d  S(   N(   t   registryR
   R$   (   R   (    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyR   H   s    	c         K   sv   | p t  } t | t i  o | g } n xB | D]: } | |  i j o t d | i   n | |  i | <q4 Wd S(   sS  
        Registers the given model(s) with the given databrowse site.

        The model(s) should be Model classes, not instances.

        If a databrowse class isn't given, it will use DefaultModelDatabrowse
        (the default databrowse options).

        If a model is already registered, this will raise AlreadyRegistered.
        s"   The model %s is already registeredN(   t   DefaultModelDatabrowset
   issubclassR   t   ModelR-   R   R   (   R   t   model_or_iterablet   databrowse_classt   optionsR   (    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyt   registerL   s     c         C   sf   t  | t i  o | g } n x? | D]7 } | |  i j o t d | i   n |  i | =q' Wd S(   s~   
        Unregisters the given model(s).

        If a model isn't already registered, this will raise NotRegistered.
        s   The model %s is not registeredN(   R/   R   R0   R-   R   R   (   R   R1   R   (    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyt
   unregister_   s     c         C   s   | i  t | i   t |   |  _ | i d  } | d j o |  i |  Sd | j o |  i | | i d d   St i d   d S(   s   
        Handles main URL routing for the databrowse app.

        `url` is the remainder of the URL -- e.g. 'comments/comment/'.
        R   R   i   s-   The requested databrowse page does not exist.N(	   t   patht   lenR$   t   rstript   indext
   model_pageR   R    R    (   R   R   R   (    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyR#   l   s    #c         C   sQ   g  } |  i  i   D] } | t |  |  q ~ } t d h | d 6|  i d 6 S(   Ns   databrowse/homepage.htmlt
   model_listR$   (   R-   t   keysR   R   R$   (   R   R   R)   t   mt   m_list(    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyR9   |   s    3c         C   s   t  i | |  } | d j o t i d | | f   n y |  i | } Wn" t j
 o t i d   n X| | |   i | |  S(   s   
        Handles the model-specific functionality of the databrowse site, delegating
        to the appropriate ModelDatabrowse class.
        s   App %r, model %r, not found.s>   This model exists but has not been registered with databrowse.N(   R   t	   get_modelR
   R    R    R-   R   R#   (   R   R   t	   app_labelt
   model_nameR!   R   R2   (    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyR:      s    N(	   R   R   R   R
   R4   R5   R#   R9   R:   (    (    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyR,   G   s   				(   t   CalendarPlugin(   t   ObjectDetailPlugin(   t   FieldChoicePluginR.   c           B   s,   e  Z h e   d  6e   d 6e   d 6Z RS(   t   objectst	   calendarst   fields(   R   R   RC   RB   RD   R   (    (    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyR.      s   N(   t   djangoR    t	   django.dbR   t(   django.contrib.databrowse.datastructuresR   t   django.shortcutsR   t   django.utils.safestringR   t	   ExceptionR   R   t   objectR	   R   R,   R   t+   django.contrib.databrowse.plugins.calendarsRB   t)   django.contrib.databrowse.plugins.objectsRC   t.   django.contrib.databrowse.plugins.fieldchoicesRD   R.   (    (    (    sI   /usr/local/lib/python2.6/dist-packages/django/contrib/databrowse/sites.pyt   <module>   s   #G	