
    	                     b    S r SSKrSSKrSSKJr  SSKJr  SSKr " S S\R                  5      r	g)z1Contains classes used for the Django ORM storage.    N)models)encodingc                   J   ^  \ rS rSrSrU 4S jrS rS rS rS r	S r
S	rU =r$ )
CredentialsField   z0Django ORM field for storing OAuth2 Credentials.c                 D   > SU;  a  SUS'   [         [        U ]
  " U0 UD6  g )NnullT)superr   __init__)selfargskwargs	__class__s      :lib/third_party/oauth2client/contrib/django_util/models.pyr   CredentialsField.__init__   s)    !F6N.??    c                     g)NBinaryField )r   s    r   get_internal_type"CredentialsField.get_internal_type"   s    r   c                 $    U R                  U5      $ )ztOverrides ``models.Field`` method. This converts the value
returned from the database to an instance of this class.
)	to_python)r   value
expression
connectioncontexts        r   from_db_valueCredentialsField.from_db_value%   s     ~~e$$r   c                     Uc  g[        U[        R                  R                  5      (       a  U$ [        R
                  " [        R                  " [        R                  " U5      5      5      $ )zvOverrides ``models.Field`` method. This is used to convert
bytes (from serialization etc) to an instance of this classN)

isinstanceoauth2clientclientCredentialspickleloadsbase64	b64decoder   smart_bytesr   r   s     r   r   CredentialsField.to_python+   sO     =|22>>??L<< 0 01E1Ee1L MNNr   c                     Uc  g[         R                  " [        R                  " [        R
                  " U5      5      5      $ )zOverrides ``models.Field`` method. This is used to convert
the value from an instances of this class to bytes that can be
inserted into the database.
N)r   
smart_textr'   	b64encoder%   dumpsr*   s     r   get_prep_valueCredentialsField.get_prep_value5   s1    
 =&&v'7'7U8K'LMMr   c                 F    U R                  U5      nU R                  U5      $ )zConvert the field value from the provided model to a string.

Used during model serialization.

Args:
    obj: db.Model, model object

Returns:
    string, the serialized field value
)_get_val_from_objr0   )r   objr   s      r   value_to_string CredentialsField.value_to_string?   s%     &&s+""5))r   r   )__name__
__module____qualname____firstlineno____doc__r   r   r   r   r0   r5   __static_attributes____classcell__)r   s   @r   r   r      s,    :@
%ON* *r   r   )
r;   r'   r%   	django.dbr   django.utilsr   r"   Fieldr   r   r   r   <module>rA      s)    8    ! 1*v|| 1*r   