HMAC Signature :keywords hmac
Code
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): |
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): |
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: |
_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 |
from collections import deque | |
import psutil | |
from settings import settings | |
from collections import AsyncIterable | |
class AsyncIteratorWrapper(AsyncIterable): | |
def __init__(self, obj): |
HMAC Signature :keywords hmac
Code
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 is an example gist combining a few different source files from our build | |
script. | |
licensed to be under MIT | |
copywrite: Matthaus Woolard 2016 matthaus.woolard@gmail.com | |
""" | |
import json | |
import os |
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, |