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 BTreeNode(object): | |
"""A B-Tree Node. | |
attributes | |
===================== | |
leaf : boolean, determines whether this node is a leaf. | |
keys : list, a list of keys internal to this node | |
c : list, a list of children of this node | |
""" | |
def __init__(self, leaf=False): |
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
# Do the first 6 steps only once. | |
1. pip install --user alembic | |
2. bash: ``cd {{my_project}} && alembic init alembic`` | |
3. bash: ``text_editor {{my_project}}/alembic.ini`` | |
4. Change: "sqlalchemy.url = postgres://{{username}}:{{password}}@{{address}}/{{db_name}}" | |
5. bash: ``text_editor {{my_project}}/alembic/env.py`` | |
6. Now, import your metadata/db object from your app.: | |
# {{my_project}}/{{my_project_dir}}/app.py | |
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
# run.py file | |
from app.app import init | |
if __name__ == "__main__": | |
init() | |
# app/app.py file | |
from sanic import Sanic |
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
# HANDLER | |
from django.utils.translation import ugettext_lazy as _ | |
from rest_framework.exceptions import ErrorDetail | |
from rest_framework.views import exception_handler | |
non_field_errors = 'non_field_errors' | |
def set_custome_errors(errors): |
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 functools import wraps | |
from django.core.cache import cache | |
from celery.five import monotonic | |
CACHE_LOCK_EXPIRE = 10 | |