î
ªÍ Xp	  ã               @   s€   d  d l  m Z d  d l m Z d  d l m Z d  d l m Z d  d l m	 Z	 Gd d „  d e ƒ Z
 Gd d	 „  d	 e
 ƒ Z d
 S)é    )Úapps)ÚGeometryField)ÚSitemap)Úmodels)Úreversec               @   sd   e  Z d  Z d Z d Z d d d „ Z d d „  Z d d d d	 d
 „ Z d d „  Z d d „  Z	 d S)Ú
KMLSitemapz1
    A minimal hook to produce KML sitemaps.
    ZkmlNc             C   s   |  j  | ƒ |  _ d  S)N)Ú_build_kml_sourcesÚ	locations)Úselfr	   © r   úM/home/ubuntu/projects/ifolica/build/django/django/contrib/gis/sitemaps/kml.pyÚ__init__   s    zKMLSitemap.__init__c             C   sî   g  } | d k r! t  j ƒ  } n  xÆ | D]¾ } t | t j j ƒ r” x  | j j D]= } t | t ƒ rP | j	 | j j
 | j j | j f ƒ qP qP Wq( t | t t f ƒ rÚ t | ƒ d k rÊ t d ƒ ‚ n  | j	 | ƒ q( t d ƒ ‚ q( W| S)zõ
        Goes through the given sources and returns a 3-tuple of
        the application label, module name, and field name of every
        GeometryField encountered in the sources.

        If no sources are provided, then all models.
        Né   z?Must specify a 3-tuple of (app_label, module_name, field_name).z)KML Sources must be a model or a 3-tuple.)r   Z
get_modelsÚ
isinstancer   ÚbaseZ	ModelBaseZ_metaÚfieldsr   ÚappendZ	app_labelZ
model_nameÚnameÚlistÚtupleÚlenÚ
ValueErrorÚ	TypeError)r
   ÚsourcesZkml_sourcesÚsourceÚfieldr   r   r   r      s     	zKMLSitemap._build_kml_sourcesé   c             C   sC   t  j |  d | d | d | ƒ} x | D] } |  j | d <q( W| S)z|
        This method is overridden so the appropriate `geo_format` attribute
        is placed on each URL element.
        ÚpageÚsiteÚprotocolÚ
geo_format)r   Úget_urlsr    )r
   r   r   r   ÚurlsÚurlr   r   r   r!   -   s    !zKMLSitemap.get_urlsc             C   s   |  j  S)N)r	   )r
   r   r   r   Úitems7   s    zKMLSitemap.itemsc             C   s8   t  d |  j d i | d d 6| d d 6| d d 6ƒS)	Nz$django.contrib.gis.sitemaps.views.%sÚkwargsr   Úlabelr   Úmodelé   Ú
field_name)r   r    )r
   Úobjr   r   r   Úlocation:   s    zKMLSitemap.location)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r    r   r   r!   r$   r+   r   r   r   r   r      s   
r   c               @   s   e  Z d  Z d Z d S)Ú
KMZSitemapZkmzN)r,   r-   r.   r    r   r   r   r   r0   E   s   r0   N)Zdjango.appsr   Z#django.contrib.gis.db.models.fieldsr   Zdjango.contrib.sitemapsr   Z	django.dbr   Zdjango.urlsr   r   r0   r   r   r   r   Ú<module>   s   =