ó
[³XMc           @   sō  d  d l  Z  d  d l Z d  d l m Z m Z d  d l m Z d  d l m Z e d d d d  Z	 e e	  Z
 e  j d e e	  f d	 e d
 Z d Z i e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6Z d  e f d!     YZ d"   Z e
 e  Z e d#  Z e
 e  Z d$   Z e
 e  Z d%   Z e
 e  Z d&   Z e
 e  Z d' d1 d(     YZ d) d2 d*     YZ d+ d, d- d  d. d/ d0 g Z d S(3   i’’’’N(   t   Versiont   getVersionString(   t
   deprecated(   t   _safet   Twistedi   i    s/   twisted.enterprise.util is deprecated since %s.t   categoryi   i   t   bigintt   boolt   booleant   byteat   datet   int2t   int4t   int8t   intt   integert   float4t   float8t   numerict   realt   smallintt   chart   textt   timet	   timestampt   varchart   DBErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/enterprise/util.pyR   /   s   c         C   s@   | j    } x- |  j D]" \ } } | | j    k r | Sq Wd  S(   N(   t   lowert   rowKeyColumnst   None(   t   rowClasst   namet   lcnamet	   keyColumnt   type(    (    s;   /usr/lib/python2.7/dist-packages/twisted/enterprise/util.pyt   getKeyColumn6   s
    c         C   s  t  j | d  } | d k r1 t d |   n  |  d k rA d S| t k rW t |   S| t k r| j d  r |  r d }  q d }  n  | d k rOd g } x |  D] } t |  } | d k rŌ | j	 d	  q¦ | d
 k rō | j	 | d  q¦ d | k od k n r | j	 |  q¦ | j	 d |  q¦ W| j	 d  d j
 |  St |  t j  rt |  t j  rt |   }  n  d | |   Sd S(   se   Add quotes for text types and no quotes for integer types.
    NOTE: uses Postgresql type codes.
    s   Type %s not knownt   nullR   t   1t   0R	   t   'i    s   \\000i\   i   i    i~   s   \%03ot    s   '%s'N(   t	   dbTypeMapt   getR   R   t   NOQUOTEt   strt   USEQUOTEt
   startswitht   ordt   appendt   joint
   isinstancet   typest
   StringTypet   UnicodeType(   t   valuet   typeCodet   string_escapert   qt   lt   ct   i(    (    s;   /usr/lib/python2.7/dist-packages/twisted/enterprise/util.pyt   quote@   s:    
			c         C   s
   t  |   S(   s<   
    Make a string safe to include in an SQL statement.
    (   R   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/enterprise/util.pyt   safef   s    c         C   sy   i  } xl t  d t |   D]U } |  j | d j   } x5 |  j D]* } | j   | k rC | | | | <PqC qC Wq W| S(   s   Utility method to construct a dictionary for the attributes
    of an object from set of args. This also fixes the case of column names.
    i    (   t   ranget   lent	   dbColumnsR   t
   rowColumns(   R    t   argst   kwR>   t
   columnNamet   attr(    (    s;   /usr/lib/python2.7/dist-packages/twisted/enterprise/util.pyt   makeKWo   s    c         C   s   |    } | j  j |  | S(   s7   Used by loadObjects to create rowObject instances.
    (   t   __dict__t   update(   R    t   dataRF   t	   newObject(    (    s;   /usr/lib/python2.7/dist-packages/twisted/enterprise/util.pyt   defaultFactoryMethod~   s    	t
   _TableInfoc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   sw   (internal)

    Info about a table/class and it's relationships. Also serves as a container for
    generated SQL.
    c         C   sĒ   | |  _  | j |  _ | j |  _ | j |  _ t | d  rK | j |  _ n	 g  |  _ t | d  r | j r{ | j |  _ q t g |  _ n t g |  _ d  |  _	 d  |  _
 d  |  _ g  |  _ g  |  _ d  S(   Nt   rowForeignKeyst   rowFactoryMethod(   R    t   rowTableNameR   RD   t   hasattrRP   RQ   RN   R   t	   updateSQLt	   deleteSQLt	   insertSQLt   relationshipsRC   (   t   selft   rc(    (    s;   /usr/lib/python2.7/dist-packages/twisted/enterprise/util.pyt   __init__   s"    							c         C   s&   |  j  j t | | | | |   d S(   så   This information is attached to the "parent" table
                childColumns - columns of the "child" table
                parentColumns - columns of the "parent" table, the one being joined to... the "foreign" table
        N(   RW   R2   t   _TableRelationship(   RX   t   childColumnst   parentColumnst   childRowClasst   containerMethodt   autoLoad(    (    s;   /usr/lib/python2.7/dist-packages/twisted/enterprise/util.pyt   addForeignKey§   s    c         C   s.   x' |  j  D] } | j j | k r
 | Sq
 Wd  S(   N(   RW   R^   RR   R   (   RX   t	   tableNamet   relationship(    (    s;   /usr/lib/python2.7/dist-packages/twisted/enterprise/util.pyt   getRelationshipForÆ   s    (   R   R   t   __doc__RZ   Ra   Rd   (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/enterprise/util.pyRO      s   		R[   c           B   s   e  Z d  Z d   Z RS(   sC   (Internal)

    A foreign key relationship between two tables.
    c         C   s1   | |  _  | |  _ | |  _ | |  _ | |  _ d  S(   N(   R\   R]   R^   R_   R`   (   RX   R\   R]   R^   R_   R`   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/enterprise/util.pyRZ   ŗ   s
    				(   R   R   Re   RZ   (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/enterprise/util.pyR[   µ   s   R-   R/   R+   R%   R@   R?   (    (    (   t   warningsR5   t   twisted.python.versionsR    R   t   twisted.python.deprecateR   t   twisted.enterprise.adbapiR   t   _deprecatedVersiont   _releasedDeprecationt   warnt   DeprecationWarningR-   R/   R+   t	   ExceptionR   R%   R?   R@   RI   RN   RO   R[   t   __all__(    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/enterprise/util.pyt   <module>   s^   
	#			-