|
Server : Apache System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64 User : njnconst ( 1116) PHP Version : 8.4.18 Disable Function : NONE Directory : /lib64/python2.7/site-packages/django/shortcuts/ |
Upload File : |
�
r�\c @ s� d Z d d l Z d d l m Z m Z d d l m Z m Z d d l m Z m Z d d l
m Z d d l m
Z
d d l m Z d d l m Z d
� Z d � Z d � Z d
� Z d � Z d � Z d � Z d S( s�
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.
i����N( t loadert RequestContext( t HttpResponset Http404( t HttpResponseRedirectt HttpResponsePermanentRedirect( t ModelBase( t Manager( t QuerySet( t urlresolversc O sm i | j d d � d 6} | j d d � } | rT t j d t d d �| | d <n t t j | | � | � S( s�
Returns a HttpResponse whose content is filled with the result of calling
django.template.loader.render_to_string() with the passed arguments.
t content_typet mimetypesE The mimetype keyword argument is deprecated, use content_type insteadt
stackleveli N( t popt Nonet warningst warnt DeprecationWarningR R t render_to_string( t argst kwargst httpresponse_kwargsR ( ( s; /tmp/pip-install-XxeQeY/django/django/shortcuts/__init__.pyt render_to_response s
c O s� i | j d d � d 6| j d d � d 6} d | k rk | j d � } | j d d � r� t d � � q� n$ | j d d � } t | d | �} | | d <t t j | | � | � S( s�
Returns a HttpResponse whose content is filled with the result of calling
django.template.loader.render_to_string() with the passed arguments.
Uses a RequestContext by default.
R
t statust context_instancet current_appsV If you provide a context_instance you must set its current_app before calling render()N( R
R t gett
ValueErrorR R R R ( t requestR R R R R ( ( s; /tmp/pip-install-XxeQeY/django/django/shortcuts/__init__.pyt render s
c O s7 | j d t � r t } n t } | t | | | � � S( s�
Returns 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: `urlresolvers.reverse()` will
be used to reverse-resolve the name.
* A URL, which will be used as-is for the redirect location.
By default issues a temporary redirect; pass permanent=True to issue a
permanent redirect
t permanent( R
t FalseR R t resolve_url( t toR R t redirect_class( ( s; /tmp/pip-install-XxeQeY/django/django/shortcuts/__init__.pyt redirect8 s c C s� t | t � r | St | t � r+ | } nO t | t � rF | j } n4 t | t � r^ | j n | j j } t d | � � | j � S( s�
Returns a QuerySet from a Model, Manager, or QuerySet. Created to make
get_object_or_404 and get_list_or_404 more DRY.
Raises a ValueError if klass is not a Model, Manager, or QuerySet.
sH Object is of type '%s', but must be a Django Model, Manager, or QuerySet(
t
isinstanceR R R t _default_managert typet __name__t __class__R t all( t klasst managert klass__name( ( s; /tmp/pip-install-XxeQeY/django/django/shortcuts/__init__.pyt
_get_querysetP s
c O sW t | � } y | j | | � SWn0 | j j k
rR t d | j j j � � n Xd S( s_
Uses get() to return an object, or raises a 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.
Note: Like with get(), an MultipleObjectsReturned will be raised if more than one
object is found.
s No %s matches the given query.N( R- R t modelt DoesNotExistR t _metat object_name( R* R R t queryset( ( s; /tmp/pip-install-XxeQeY/django/django/shortcuts/__init__.pyt get_object_or_404d s
c O sJ t | � } t | j | | � � } | sF t d | j j j � � n | S( s�
Uses filter() to return a list of objects, or raise a 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.
s No %s matches the given query.( R- t listt filterR R. R0 R1 ( R* R R R2 t obj_list( ( s; /tmp/pip-install-XxeQeY/django/django/shortcuts/__init__.pyt get_list_or_404u s
c O s� t | d � r | j � Sy t j | d | d | �SWnD t j k
r| t | � r[ � n d | k r} d | k r} � q} n X| S( sV
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: `urlresolvers.reverse()` will
be used to reverse-resolve the name.
* A URL, which will be returned as-is.
t get_absolute_urlR R t /t .( t hasattrR8 R t reverset NoReverseMatcht callable( R! R R ( ( s; /tmp/pip-install-XxeQeY/django/django/shortcuts/__init__.pyR � s
( t __doc__R t django.templateR R t django.httpR R R R t django.db.models.baseR t django.db.models.managerR t django.db.models.queryR t django.coreR R R R# R- R3 R7 R ( ( ( s; /tmp/pip-install-XxeQeY/django/django/shortcuts/__init__.pyt <module> s