o 3aN@sddlZddlZddlZddlmZGdddeZGdddeZeZ GdddZ Gd d d e Z Gd d d e Z Gd ddZdS)N) sync_to_asyncc@ eZdZdS)RemovedInDjango40WarningN__name__ __module__ __qualname__r r :/usr/lib/python3/dist-packages/django/utils/deprecation.pyrrc@r)RemovedInDjango41WarningNrr r r r r r r c@seZdZddZddZdS)warn_about_renamed_methodcCs||_||_||_||_dSN) class_nameold_method_namenew_method_namedeprecation_warning)selfrrrrr r r __init__s z"warn_about_renamed_method.__init__csfdd}|S)Ncs.tdjjjfjd|i|S)Nz(`%s.%s` is deprecated, use `%s` instead.)warningswarnrrrr)argskwargsfrr r wrappedsz3warn_about_renamed_method.__call__..wrappedr )rrrr rr __call__sz"warn_about_renamed_method.__call__N)rrrrrr r r r r s r cs$eZdZdZdZfddZZS)RenameMethodsBasea# Handles the deprecation paths when renaming a method. It does the following: 1) Define the new method if missing and complain about it. 2) Define the old method if missing. 3) Complain whenever an old method is called. See #15363 for more details. r cst||||}t|D]U}|j}|jD]L}|d}|j|} |d} |j| } |d} t|g|R} | sV| rVt d||| f| dt || | t ||| | | sb| rbt ||| | qq|S)Nrrz&`%s.%s` method should be renamed `%s`.) super__new__inspectgetmrorrenamed_methods__dict__getr rrsetattr)clsnamebasesattrs new_classbaserrenamed_methodr old_methodr new_methodrwrapper __class__r r r!2s0    zRenameMethodsBase.__new__)rrr__doc__r$r! __classcell__r r r2r r$s rcseZdZfddZZS)DeprecationInstanceCheckcs(td|j|jf|jdt|S)Nz%`%s` is deprecated, use `%s` instead.r)rrr alternativerr __instancecheck__)rinstancer2r r r8Ps  z*DeprecationInstanceCheck.__instancecheck__)rrrr8r5r r r2r r6Osr6csFeZdZdZdZd fdd ZddZddZd d Zd d Z Z S)MiddlewareMixinTNcs&||||_|tdSr)_get_response_none_deprecation get_response _async_checkr rrr<r2r r r^s zMiddlewareMixin.__init__cCst|jr tjj|_dSdS)z If get_response is a coroutine function, turns us into async mode so a thread is not consumed during a whole request. N)asyncioiscoroutinefunctionr< coroutines _is_coroutine)rr r r r=ds zMiddlewareMixin._async_checkcCsVt|jr ||Sd}t|dr||}|p||}t|dr)|||}|S)Nprocess_requestprocess_response)r?r@r< __acall__hasattrrCrDrrequestresponser r r rns      zMiddlewareMixin.__call__csdd}t|drt|jdd|IdH}|p||IdH}t|dr0t|jdd||IdH}|S)zh Async version of __call__ that is swapped in when an async request is running. NrCT)thread_sensitiverD)rFrrCr<rDrGr r r rEzs$    zMiddlewareMixin.__acall__cCs |durtjdtdddSdS)NzDPassing None for the middleware get_response argument is deprecated.) stacklevel)rrrr>r r r r;s  z.MiddlewareMixin._get_response_none_deprecationr) rrr sync_capable async_capablerr=rrEr;r5r r r2r r:Xs  r:)r?r"r asgiref.syncrDeprecationWarningrPendingDeprecationWarningr RemovedInNextVersionWarningr typerr6r:r r r r s +