Current File : //usr/local/apps/python3/lib/python3.11/site-packages/django/__pycache__/shortcuts.cpython-311.pyc
�

�rRhj���dZddlmZmZmZmZddlmZddlm	Z	m
Z
ddlmZ	dd�Z
ddd	�d
�Zd�Zd�Zd
�Zd�Zd�Zd�ZdS)z�
This module collects helper functions and classes that "span" multiple levels
of MVC. In other words, these functions/classes introduce controlled coupling
for convenience's sake.
�)�Http404�HttpResponse�HttpResponsePermanentRedirect�HttpResponseRedirect)�loader)�NoReverseMatch�reverse)�PromiseNc�T�tj||||���}t|||��S)z�
    Return an HttpResponse whose content is filled with the result of calling
    django.template.loader.render_to_string() with the passed arguments.
    )�using)r�render_to_stringr)�request�
template_name�context�content_type�statusr�contents       �H/usr/local/apps/python3/lib/python3.11/site-packages/django/shortcuts.py�renderrs/���%�m�W�g�U�S�S�S�G����v�6�6�6�F)�	permanent�preserve_requestc�X�|rtnt}|t|g|�Ri|��|���S)ak
    Return an HttpResponseRedirect to the appropriate URL for the arguments
    passed.

    The arguments could be:

        * A model: the model's `get_absolute_url()` function will be called.

        * A view name, possibly with arguments: `urls.reverse()` will be used
          to reverse-resolve the name.

        * A URL, which will be used as-is for the redirect location.

    Issues a temporary redirect by default. Set permanent=True to issue a
    permanent redirect. Set preserve_request=True to instruct the user agent
    to preserve the original HTTP method and body when following the redirect.
    )r)rr�resolve_url)�torr�args�kwargs�redirect_classs      r�redirectrsQ��&*3�L�%�%�8L���>��B�(��(�(�(��(�(�)����rc�X�t|d��r|j���S|S)z�
    Return a QuerySet or a Manager.
    Duck typing in action: any class with a `get()` method (for
    get_object_or_404) or a `filter()` method (for get_list_or_404) might do
    the job.
    �_default_manager)�hasattrr!�all)�klasss r�
_get_querysetr%8s1���u�(�)�)�,��%�)�)�+�+�+��Lrc�8�t|��}t|d��s:t|t��r|jn|jj}t
d|z���	|j|i|��S#|jj	$r"td|jjjz���wxYw)aY
    Use get() to return an object, or raise an Http404 exception if the object
    does not exist.

    klass may be a Model, Manager, or QuerySet object. All other passed
    arguments and keyword arguments are used in the get() query.

    Like with QuerySet.get(), MultipleObjectsReturned is raised if more than
    one object is found.
    �getzVFirst argument to get_object_or_404() must be a Model, Manager, or QuerySet, not '%s'.�No %s matches the given query.)
r%r"�
isinstance�type�__name__�	__class__�
ValueErrorr'�model�DoesNotExistr�_meta�object_name�r$rr�queryset�klass__names     r�get_object_or_404r5Es����U�#�#�H��8�U�#�#�
�(���5�5�S�E�N�N�5�?�;S�	��
%�'2�
3�
�
�	
�
��x�|�T�,�V�,�,�,���>�&�
�
�
��,�x�~�/C�/O�O�
�
�	
�
���s�A(�(1Bc��LK�t|��}t|d��s;t|t��r|jn|jj}t
d|�d����	|j|i|���d{V��S#|jj	$r#td|jjj�d����wxYw)zSee get_object_or_404().�agetzSFirst argument to aget_object_or_404() must be a Model, Manager, or QuerySet, not '�'.N�No � matches the given query.)
r%r"r)r*r+r,r-r7r.r/rr0r1r2s     r�aget_object_or_404r;as������U�#�#�H��8�V�$�$�
�(���5�5�S�E�N�N�5�?�;S�	��
.�)�
.�
.�
.�
�
�	
�Y�"�X�]�D�3�F�3�3�3�3�3�3�3�3�3���>�&�Y�Y�Y��W�H�N�0�<�W�W�W�X�X�X�Y���s�A1�12B#c�2�t|��}t|d��s:t|t��r|jn|jj}t
d|z���t|j|i|����}|s!td|j
jjz���|S)z�
    Use filter() to return a list of objects, or raise an Http404 exception if
    the list is empty.

    klass may be a Model, Manager, or QuerySet object. All other passed
    arguments and keyword arguments are used in the filter() query.
    �filterzTFirst argument to get_list_or_404() must be a Model, Manager, or QuerySet, not '%s'.r()
r%r"r)r*r+r,r-�listr=rr.r0r1�r$rrr3r4�obj_lists      r�get_list_or_404rArs����U�#�#�H��8�X�&�&�
�(���5�5�S�E�N�N�5�?�;S�	��
"�$/�
0�
�
�	
��O�H�O�T�4�V�4�4�5�5�H��
��,�x�~�/C�/O�O�
�
�	
��Orc��@K�t|��}t|d��s;t|t��r|jn|jj}t
d|�d����d�|j|i|��2���d{V��}|s"td|j	j
j�d����|S)zSee get_list_or_404().r=zQFirst argument to aget_list_or_404() must be a Model, Manager, or QuerySet, not 'r8c��"K�g|3d{V��}|��
6S)N�)�.0�objs  r�
<listcomp>z$aget_list_or_404.<locals>.<listcomp>�s.����F�F�F�F�F�F�F�F�c��F�F�F�Fs�Nr9r:)r%r"r)r*r+r,r-r=rr.r0r1r?s      r�aget_list_or_404rH�s������U�#�#�H��8�X�&�&�
�(���5�5�S�E�N�N�5�?�;S�	��
.�)�
.�
.�
.�
�
�	
�G�F�_�X�_�d�%E�f�%E�%E�F�F�F�F�F�F�F�F�F�H��Y��W�H�N�0�<�W�W�W�X�X�X��Orc�f�t|d��r|���St|t��rt	|��}t|t��r|�d��r|S	t
|||���S#t$rt|��r�d|vrd|vr�YnwxYw|S)aM
    Return a URL appropriate for the arguments passed.

    The arguments could be:

        * A model: the model's `get_absolute_url()` function will be called.

        * A view name, possibly with arguments: `urls.reverse()` will be used
          to reverse-resolve the name.

        * A URL, which will be returned as-is.
    �get_absolute_url)z./z../)rr�/�.)	r"rJr)r
�str�
startswithr	r�callable)rrrs   rrr�s����r�%�&�&�%��"�"�$�$�$��"�g������W�W���"�c����r�}�}�]�;�;���	���r��V�4�4�4�4�������B�<�<�	���b�=�=�S��]�]����
�����Is�6B�#B.�-B.)NNNN)�__doc__�django.httprrrr�django.templater�django.urlsrr	�django.utils.functionalr
rrr%r5r;rArHrrDrr�<module>rUs+����������������#�"�"�"�"�"�/�/�/�/�/�/�/�/�+�+�+�+�+�+�QU�7�7�7�7�#(�%������6
�
�
�
�
�
�8Y�Y�Y�"���2���"&�&�&�&�&r