Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
djangorestframework / __pycache__ / viewsets.cpython-35.pyc
Size: Mime:


«¬šYWã	@s
dZddlmZddlmZddlmZddlmZddl	m
Z
mZmZGdd„de
ƒZGd	d
„d
eejƒZGdd„dee
jƒZGd
d„dejejeƒZGdd„dejejejejejeƒZdS)a
ViewSets are essentially just a type of class based view, that doesn't provide
any method handlers, such as `get()`, `post()`, etc... but instead has actions,
such as `list()`, `retrieve()`, `create()`, etc...

Actions are only bound to methods at the point of instantiating the views.

    user_list = UserViewSet.as_view({'get': 'list'})
    user_detail = UserViewSet.as_view({'get': 'retrieve'})

Typically, rather than instantiate views from viewsets directly, you'll
register the viewset with a router and let the URL conf be determined
automatically.

    router = DefaultRouter()
    router.register(r'users', UserViewSet, 'user')
    urlpatterns = router.urls
é)Úunicode_literals)Úupdate_wrapper)Úclassonlymethod)Úcsrf_exempt)ÚgenericsÚmixinsÚviewscs=eZdZdZeddd„ƒZ‡fdd†Z‡S)ÚViewSetMixinad
    This is the magic.

    Overrides `.as_view()` so that it takes an `actions` keyword that performs
    the binding of HTTP methods to actions on the Resource.

    For example, to create a concrete view binding the 'GET' and 'POST' methods
    to the 'list' and 'create' actions...

    view = MyViewSet.as_view({'get': 'list', 'post': 'create'})
    Ncs÷dˆ_ˆstdƒ‚x^ˆD]V}|ˆjkrPtd|ˆjfƒ‚tˆ|ƒs"tdˆj|fƒ‚q"W‡‡‡fdd†}t|ˆdfƒt|ˆjdfƒˆ|_ˆ|_ˆj	d	dƒ|_ˆ|_
t|ƒS)
zä
        Because of the way class based views create a closure around the
        instantiated view, we need to totally reimplement `.as_view`,
        and slightly modify the view function that is created and returned.
        NzwThe `actions` argument must be provided when calling `.as_view()` on a ViewSet. For example `.as_view({'get': 'list'})`zUYou tried to pass in the %s method name as a keyword argument to %s(). Don't do that.z#%s() received an invalid keyword %rcsªˆˆ}ˆ|_x9ˆjƒD]+\}}t||ƒ}t|||ƒq"Wt|dƒr|t|dƒr||j|_||_||_||_	|j
|||ŽS)NÚgetÚhead)Ú
action_mapÚitemsÚgetattrÚsetattrÚhasattrr
rÚrequestÚargsÚkwargsÚdispatch)rrrÚselfÚmethodÚactionÚhandler)ÚactionsÚclsÚ
initkwargs©úV/Users/carlton/Documents/Django-Stack/django-rest-framework/rest_framework/viewsets.pyÚviewEs				z"ViewSetMixin.as_view.<locals>.viewÚupdatedÚassignedÚsuffix)r!Ú	TypeErrorÚhttp_method_namesÚ__name__rrrrrr
rr)rrrÚkeyrr)rrrrÚas_view*s$		
			zViewSetMixin.as_viewcs^tt|ƒj|||Ž}|jjƒ}|dkrEd|_n|jj|ƒ|_|S)zc
        Set the `.action` attribute on the view,
        depending on the request method.
        ÚoptionsÚmetadata)Úsuperr	Úinitialize_requestrÚlowerrrr
)rrrrr)Ú	__class__rrr*lszViewSetMixin.initialize_request)r$Ú
__module__Ú__qualname__Ú__doc__rr&r*rr)r,rr	sAr	c@seZdZdZdS)ÚViewSetzI
    The base ViewSet class does not provide any actions by default.
    N)r$r-r.r/rrrrr0}sr0c@seZdZdZdS)ÚGenericViewSetzÀ
    The GenericViewSet class does not provide any actions by default,
    but does include the base set of generic view behavior, such as
    the `get_object` and `get_queryset` methods.
    N)r$r-r.r/rrrrr1„sr1c@seZdZdZdS)ÚReadOnlyModelViewSetzL
    A viewset that provides default `list()` and `retrieve()` actions.
    N)r$r-r.r/rrrrr2sr2c@seZdZdZdS)ÚModelViewSetz‰
    A viewset that provides default `create()`, `retrieve()`, `update()`,
    `partial_update()`, `destroy()` and `list()` actions.
    N)r$r-r.r/rrrrr3–s	r3N)r/Ú
__future__rÚ	functoolsrÚdjango.utils.decoratorsrÚdjango.views.decorators.csrfrÚrest_frameworkrrrÚobjectr	ÚAPIViewr0ÚGenericAPIViewr1ÚRetrieveModelMixinÚListModelMixinr2ÚCreateModelMixinÚUpdateModelMixinÚDestroyModelMixinr3rrrrÚ<module>s"`