ó
J~‰Pc           @  sP   d  Z  d d l m Z d d l m Z d d l m Z d e f d „  ƒ  YZ d S(   uL   
 This object provides quoting for GEOS geometries into PostgreSQL/PostGIS.
iÿÿÿÿ(   t   unicode_literals(   t   Binary(   t	   ISQLQuotet   PostGISAdapterc           B  sG   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C  s4   t  | j ƒ |  _ | j |  _ t |  j ƒ |  _ d S(   u   Initializes on the geometry.N(   t   bytest   ewkbt   sridR   t   _adapter(   t   selft   geom(    (    sG   ../Django//lib/python/django/contrib/gis/db/backends/postgis/adapter.pyt   __init__
   s    c         C  s    | t  k r |  St d ƒ ‚ d  S(   Nu<   Error implementing psycopg2 protocol. Is psycopg2 installed?(   R   t	   Exception(   R   t   proto(    (    sG   ../Django//lib/python/django/contrib/gis/db/backends/postgis/adapter.pyt   __conform__   s    c         C  s5   t  | t ƒ s t S|  j | j k o4 |  j | j k S(   N(   t
   isinstanceR   t   FalseR   R   (   R   t   other(    (    sG   ../Django//lib/python/django/contrib/gis/db/backends/postgis/adapter.pyt   __eq__   s    c         C  s
   |  j  ƒ  S(   N(   t	   getquoted(   R   (    (    sG   ../Django//lib/python/django/contrib/gis/db/backends/postgis/adapter.pyt   __str__   s    c         C  s   |  j  j | ƒ d S(   uŒ   
        This method allows escaping the binary in the style required by the
        server's `standard_conforming_string` setting.
        N(   R   t   prepare(   R   t   conn(    (    sG   ../Django//lib/python/django/contrib/gis/db/backends/postgis/adapter.pyR   !   s    c         C  s   t  d |  j j ƒ  j ƒ  ƒ S(   u?   Returns a properly quoted string for use in PostgreSQL/PostGIS.u   ST_GeomFromEWKB(%s)(   t   strR   R   t   decode(   R   (    (    sG   ../Django//lib/python/django/contrib/gis/db/backends/postgis/adapter.pyR   (   s    c         C  s   |  S(   N(    (   R   t   unused(    (    sG   ../Django//lib/python/django/contrib/gis/db/backends/postgis/adapter.pyt   prepare_database_save-   s    (	   t   __name__t
   __module__R
   R   R   R   R   R   R   (    (    (    sG   ../Django//lib/python/django/contrib/gis/db/backends/postgis/adapter.pyR   	   s   						N(	   t   __doc__t
   __future__R    t   psycopg2R   t   psycopg2.extensionsR   t   objectR   (    (    (    sG   ../Django//lib/python/django/contrib/gis/db/backends/postgis/adapter.pyt   <module>   s   