
    C                         S r SSKrSSKrSSKrSSKJr  / SQrSrSrSr	S\	-  r
\R                  " \
5      r " S	 S
\5      r\R                  " S\R                   5      rS rS rS rS r " S S\5      r\4S jrg)zControl the namespacing system used by various APIs.

A namespace may be specified in various API calls exemplified
by the datastore and memcache interfaces.  The default can be
specified using this module.
    N)
lib_config)BadValueErrorset_namespaceget_namespacegoogle_apps_namespaceenable_request_namespacevalidate_namespace"HTTP_X_APPENGINE_DEFAULT_NAMESPACE"HTTP_X_APPENGINE_CURRENT_NAMESPACEd   z^[0-9A-Za-z._-]{0,%s}$c                       \ rS rSrS rSrg)_ConfigDefaults:   c                      g N r       Glib/googlecloudsdk/appengine/api/namespace_manager/namespace_manager.pydefault_namespace_for_request-_ConfigDefaults.default_namespace_for_request;   s    r   r   N)__name__
__module____qualname____firstlineno__r   __static_attributes__r   r   r   r   r   :   s    r   r   namespace_manager_c                     U c%  [         R                  R                  [        S5        g[	        U 5        U [         R                  [        '   g)zSet the default namespace for the current HTTP request.

Args:
  namespace: A string naming the new namespace to use. A value of None
    will unset the default namespace value.
N)osenvironpop_ENV_CURRENT_NAMESPACEr	   )	namespaces    r   r   r   @   s4     JJNN)40y!)2BJJ%&r   c                      [         R                  R                  [        S5      n U c"  [        R                  5       n U b  [        U 5        U c  Sn U $ )z=Get the current default namespace or ('') namespace if unset.N )r   r   getr!   _configr   r   )names    r   r   r   N   sG    	.	5$	\002DD	\D	+r   c                  J    [         R                  R                  [        S 5      $ r   )r   r   r%   _ENV_DEFAULT_NAMESPACEr   r   r   r   r   Z   s    	.	55r   c                      [         R                  " S[        SS9  [        [        R
                  ;  aF  [        [        R
                  ;   a-  [        R
                  [           [        R
                  [        '   ggg)a\  Set the default namespace to the Google Apps domain referring this request.

This method is deprecated, use lib_config instead.

Calling this function will set the default namespace to the
Google Apps domain that was used to create the url used for this request
and only for the current request and only if the current default namespace
is unset.

zSnamespace_manager.enable_request_namespace() is deprecated: use lib_config instead.   )
stacklevelN)warningswarnDeprecationWarningr!   r   r   r)   r   r   r   r   r   ]   sX     -- *" 2::-++-::6L+Mbjj'( , .r   c                       \ rS rSrSrSrg)r   q   z"Raised by ValidateNamespaceString.r   N)r   r   r   r   __doc__r   r   r   r   r   r   q   s    *r   r   c                     [        U [        5      (       d  U" SU < S[        U 5      < S35      e[        R	                  U 5      (       d  U" SU < S[
        < S35      eg)zRaises an exception if value is not a valid Namespace string.

A namespace must match the regular expression ([0-9A-Za-z._-]{0,100}).

Args:
  value: string, the value to validate.
  exception: exception type to raise.
z#value should be a string; received z (a z):zvalue "z" does not match regex ""N)
isinstance
basestringtype_NAMESPACE_REmatch_NAMESPACE_PATTERN)value	exceptions     r   r	   r	   u   sZ     
E:	&	&
DK) * *			U	#	#
.0 1 1 
$r   )r2   r   rer-   googlecloudsdk.appengine.apir   __all__r)   r!   _NAMESPACE_MAX_LENGTHr:   compiler8   objectr   register__dict__r&   r   r   r   r   	Exceptionr   r	   r   r   r   <module>rF      s     
 	  3 > =   .1FF 

-.f  

2O4L4L
M3	6N(+I + )6 1r   