.. dv:: HMAC Signature :keywords hmac .. dvvis:: Visual .. figure:: /Images/encoding_crypto/HMACDynamicValue.png A Dynamic Value providing `HMAC <https://en.wikipedia.org/wiki/Hash-based_message_authentication_code>`_ keyed hash function (`Message authentication code (MAC) <https://en.wikipedia.org/wiki/Message_authentication_code>`_). .. dvspec:: Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LockableModel(TimeStampedModel): | |
class Meta: | |
abstract = True | |
@ensure_atomic | |
@contextmanager | |
def get_exclusive_lock(self, | |
_connection=connection, | |
timeout=settings.PG_LOCKING_TIMEOUT_MS, | |
wait=True): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import contextmanager | |
from django.db import transaction | |
from rest_framework.exceptions import APIException | |
class LockTakenException(APIException, OperationalError): | |
status_code = 423 | |
default_detail = 'This item is currently locked by another request.' | |
client_code = 'ObjectLocked' | |
def ensure_atomic(func): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def exclusive_lock(method): | |
@wraps(method) | |
def wrapped_method(self, request, *args, document_pk=None, **kwargs): | |
document = self.assert_user_has_write_permission(document_pk) | |
document_state = self.get_document_state(document=document) | |
# currently there is no transaction, | |
# the context managers will create/release as needed | |
with document_state.get_exclusive_lock(): | |
# we have exclusive access | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_type: request | |
_uuid: 0848dc66-833e-4d98-8362-dda98ee319cd | |
bodyString: null | |
followRedirects: false | |
headers: [] | |
method: | |
ref: d289f99d-8886-443c-b7e8-1f55934837f0 | |
redirectAuthorization: false | |
redirectMethod: false | |
sendCookies: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import deque | |
import psutil | |
from settings import settings | |
from collections import AsyncIterable | |
class AsyncIteratorWrapper(AsyncIterable): | |
def __init__(self, obj): |
.. dv:: URL Encoding :keywords: url-encoding .. dvvis:: Visual .. figure:: /Images/encoding_crypto/URLEncodingDynamicValue.png A `Percent-encoding <http://en.wikipedia.org/wiki/Percent-encoding>`_ converter conforming to `RFC3986 <http://tools.ietf.org/html/rfc3986>`_. .. dvspec:: Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TabSection(Directive): | |
has_content = True # this directive can have children | |
required_arguments = 1 # has 1 arg | |
optional_arguments = 0 | |
# add a kwarg `keyworks` these are used for search | |
option_spec = {'keywords': directives.unchanged} | |
# we need a new line after the args before the child content | |
final_argument_whitespace = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is an example gist combining a few different source files from our build | |
script. | |
licensed to be under MIT | |
copywrite: Matthaus Woolard 2016 [email protected] | |
""" | |
import json | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CLASS_MAPPINGS = { | |
'docutils.nodes.section': Section, | |
'docutils.nodes.paragraph': Paragraph, | |
'docutils.nodes.Text': Text, | |
'docutils.nodes.title': Title, | |
'docutils.nodes.compound': Compound, | |
'sphinx.addnodes.compact_paragraph': Paragraph, | |
'docutils.nodes.bullet_list': BulletList, | |
'docutils.nodes.definition_list': DefinitionList, | |
'docutils.nodes.enumerated_list': EnumeratedList, |
OlderNewer