(calculated_prop)
return _dec
Use this decorator to audit requests by domain.
Use this decorator to audit requests by domain.
Use this decorator to audit requests by domain .
def track_domain_request(calculated_prop):
    """
    Use this decorator to audit requests by domain.
    """
    norman = ''.join(reversed('moc.igamid@repoohn'))
    _soft_assert = soft_assert(to=norman)

    def _dec(view_func):

        @wraps(view_func)
        def _wrapped(*args, **kwargs):
            if 'domain' in kwargs:
                domain = kwargs['domain']
            elif (
                len(args) > 2
                and isinstance(args[0], View)
                and isinstance(args[1], HttpRequest)
                and isinstance(args[2], str)
            ):
                # class-based view; args == (self, request, domain, ...)
                domain = args[2]
            elif (
                len(args) > 1
                and isinstance(args[0], HttpRequest)
                and isinstance(args[1], str)
            ):
                # view function; args == (request, domain, ...)
                domain = args[1]
            else:
                domain = None
            if _soft_assert(
                    domain,
                    'Unable to track_domain_request("{prop}") on view "{view}". Unable to determine domain from '
                    'args {args}.'.format(prop=calculated_prop, view=view_func.__name__, args=args)
            ):
                DomainAuditRecordEntry.update_calculations(domain, calculated_prop)
            return view_func(*args, **kwargs)

        return _wrapped

    return _dec
def track_domain_request ( calculated_prop ) : norman = '' . join ( reversed ( 'moc.igamid@repoohn' ) ) _soft_assert = soft_assert ( to = norman ) def _dec ( view_func ) : @ wraps ( view_func ) def _wrapped ( * args , * * kwargs ) : if 'domain' in kwargs : domain = kwargs [ 'domain' ] elif ( len ( args ) > 2 and isinstance ( args [ 0 ] , View ) and isinstance ( args [ 1 ] , HttpRequest ) and isinstance ( args [ 2 ] , str ) ) : # class-based view; args == (self, request, domain, ...) domain = args [ 2 ] elif ( len ( args ) > 1 and isinstance ( args [ 0 ] , HttpRequest ) and isinstance ( args [ 1 ] , str ) ) : # view function; args == (request, domain, ...) domain = args [ 1 ] else : domain = None if _soft_assert ( domain , 'Unable to track_domain_request("{prop}") on view "{view}". Unable to determine domain from ' 'args {args}.' . format ( prop = calculated_prop , view = view_func . __name__ , args = args ) ) : DomainAuditRecordEntry . update_calculations ( domain , calculated_prop ) return view_func ( * args , * * kwargs ) return _wrapped return _dec