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.security import NO_PERMISSION_REQUIRED | |
def includeme(config): | |
config.add_directive( | |
'add_cors_preflight_handler', add_cors_preflight_handler) | |
config.add_route_predicate('cors_preflight', CorsPreflightPredicate) | |
config.add_subscriber(add_cors_to_response, 'pyramid.events.NewResponse') | |
class CorsPreflightPredicate(object): |
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 _build_facade(): | |
import sys | |
from .meta.api import scan | |
this = sys.modules[__name__] | |
registry = {} | |
scan(this, registry=registry) | |
globals().update(registry) | |
_build_facade() | |
del _build_facade |
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
class StaticFactory(object): | |
def __init__(self, request): | |
request.is_static_asset = True | |
config.add_static_view('static', static_pkg, factory=StaticFactory) | |
config.add_request_method(lambda r: False, 'is_static_asset', reify=True) | |
_default_vary = set([ | |
'Cookie', | |
'Accept', |
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.authorization import ACLAuthorizationPolicy | |
from pyramid.security import ( | |
Authenticated, | |
Everyone, | |
) | |
log = __import__('logging').getLogger(__name__) | |
class OAuthAuthenticationPolicy(object): | |
def unauthenticated_userid(self, 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 pyramid.httpexceptions import HTTPSeeOther | |
from pyramid.view import view_config | |
@view_config(...) | |
def login_view(request): | |
# ... validate the user | |
user = # ... | |
next_url = request.route_url('home') | |
headers = remember(request, user.id) | |
# bind the session to the user upon login |
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 collections | |
class DictProxy(collections.Mapping): | |
""" | |
A proxy for a dictionary that allows attribute access to underlying keys. | |
You may pass a custom ``wrapper`` to override the logic for wrapping | |
various custom types. | |
""" |
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 React from 'react'; | |
import {connect} from 'redux/react'; | |
import {bindActions} from './utils/bindActions'; | |
import * as Actions from './actions'; | |
@connect(state => ({ | |
activePage: state.activePage, | |
})) | |
@bindActions({ |
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 .meta import DBSession | |
from .users import User | |
from .entries import Entry |
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 logging.config | |
import os.path | |
from alembic import context | |
from sqlalchemy import create_engine, pool | |
# this is the Alembic Config object, which provides | |
# access to the values within the .ini file in use. | |
config = context.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 pyramid.config import Configurator | |
from pyramid.view import view_config | |
def main(global_config, **app_settings): | |
config = Configurator(settings=app_settings) | |
config.include('.model') | |
config.scan(__name__) | |
return config.make_wsgi_app() | |