This file contains hidden or 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 add_localized_route(config, name, pattern, factory=None, pregenerator=None, **kw): | |
| orig_factory = factory | |
| def wrapper_factory(request): | |
| lang = request.matchdict['lang'] | |
| # determine if this is a supported lang and convert it to a locale, | |
| # likely defaulting to your default language if the requested one is | |
| # not supported by your app | |
| request._LOCALE_ = lang | |
| if orig_factory: | |
| return orig_factory(request) |
This file contains hidden or 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 alembic.config import Config | |
| from alembic.command import stamp | |
| from alembic.command import upgrade | |
| from alembic.migration import MigrationContext | |
| from myapp.model.meta import metadata | |
| from myapp.model.meta import get_engine | |
| log = __import__('logging').getLogger(__name__) |
This file contains hidden or 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
| import threading | |
| import time | |
| import transaction | |
| from .models import get_tm_session | |
| def worker(dbsession_factory, registry): | |
| while True: | |
| tm = transaction.TransactionManager(explicit=True) | |
| with tm: |
This file contains hidden or 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
| import jinja2 | |
| from pyramid.renderers import render | |
| from pyramid.threadlocal import get_current_request | |
| from translationstring import TranslationString | |
| import uuid | |
| from myapp.utils.i18n import DEFAULT_DOMAIN | |
| log = __import__('logging').getLogger(__name__) |
This file contains hidden or 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
| release: ./entrypoint.sh run alembic -c site.ini upgrade head | |
| web: ./entrypoint.sh run pserve site.ini |
This file contains hidden or 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
| pyramid_retry +--------> if exc not retryable, render response | |
| if exc retryable, ignore exc and try again | |
| + | |
| | | |
| | | |
| v | |
| pyramid_debugtoolbar | |
| + |
This file contains hidden or 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 pyramid.authentication import BasicAuthAuthenticationPolicy | |
| from pyramid.authorization import ACLAuthorizationPolicy | |
| from pyramid.config import Configurator | |
| from pyramid.httpexceptions import HTTPForbidden | |
| from pyramid.httpexceptions import HTTPUnauthorized | |
| from pyramid.security import ALL_PERMISSIONS | |
| from pyramid.security import Allow | |
| from pyramid.security import Authenticated | |
| from pyramid.security import forget | |
| from pyramid.view import forbidden_view_config |
This file contains hidden or 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, suppress | |
| from transaction.interfaces import NoTransaction | |
| class DoomedAbort(Exception): | |
| pass | |
| @contextmanager | |
| def tm_context(tm): | |
| tm.begin() | |
| try: |
This file contains hidden or 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 nacl.bindings.crypto_secretstream import ( | |
| crypto_secretstream_xchacha20poly1305_ABYTES, | |
| crypto_secretstream_xchacha20poly1305_HEADERBYTES, | |
| crypto_secretstream_xchacha20poly1305_KEYBYTES, | |
| crypto_secretstream_xchacha20poly1305_TAG_MESSAGE, | |
| crypto_secretstream_xchacha20poly1305_TAG_FINAL, | |
| crypto_secretstream_xchacha20poly1305_init_pull, | |
| crypto_secretstream_xchacha20poly1305_init_push, | |
| crypto_secretstream_xchacha20poly1305_pull, | |
| crypto_secretstream_xchacha20poly1305_push, |
This file contains hidden or 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
| DEBUG=yes | |
| AUTH_SECRET=seekrit | |
| AUTH_EXPIRES=3600 | |
| HTTPS_ONLY=no | |
| WEB_CONCURRENCY=4 | |
| TRUSTED_PROXY=127.0.0.1 | |
| BIND_HOST=127.0.0.1 |