Example #1
0
from externals.lib.misc import decorator_combine
from externals.lib.pyramid_helpers.auto_format import auto_format_output, action_ok, action_error

__all__ = [
    'web',
    'action_ok',
    'action_error',
]


def allow_cors(func):
    def inner(request, **kwargs):
        request.response.headerlist.extend([('Access-Control-Allow-Origin',
                                             '*')])
        return func(request, **kwargs)

    return inner


web = decorator_combine(
    allow_cors,
    auto_format_output,
)
Example #2
0
#-------------------------------------------------------------------------------
# Global Variables
#-------------------------------------------------------------------------------

from dogpile.cache import make_region
from dogpile.cache.api import NO_VALUE as cache_none

cache = make_region().configure(
    'dogpile.cache.memory'
)


web = decorator_combine(
    gzip,
    auto_format_output,
    overlay_session_identity(('id','admin','faves','comunity')),
    mark_external_request
)


#-------------------------------------------------------------------------------
# State
#-------------------------------------------------------------------------------

# AllanC - need to look into Pyramids security model
def is_admin(request):
    return request.session.get('admin',False)  # request.session['admin']

def is_comunity(request):
    return request.session.get('comunity',{}).get('approved', False)
Example #3
0
    if request.session.peek_flash():
        raise LookupError  # Response is not cacheable/indexable if there is a custom flash message
    return is_admin(request)


cache_manager = CacheManager(
    cache_store=cache_store,
    default_cache_key_generators=(
        CacheFunctionWrapper(_cache_key_etag_expire, ('request', )),
        CacheFunctionWrapper(_cache_key_identity_admin, ('request', )),
    ),
    default_invalidate_callbacks=(CacheFunctionWrapper(commit, ()), ))

web = decorator_combine(
    #gzip,
    #auto_format_output,
    #overlay_messages(),
    mark_external_request)

#-------------------------------------------------------------------------------
# State
#-------------------------------------------------------------------------------


# AllanC - need to look into Pyramids security model
def is_admin(request):
    return request.session.get('admin', False)  # request.session['admin']


def is_comunity(request):
    return request.session.get('user', {}).get('approved', False)
Example #4
0
#-------------------------------------------------------------------------------
# Global Variables
#-------------------------------------------------------------------------------

from dogpile.cache import make_region
from dogpile.cache.api import NO_VALUE as cache_none

cache = make_region().configure(
    'dogpile.cache.memory'
)


web = decorator_combine(
    gzip,
    auto_format_output,
    overlay_session_identity(('id', 'admin', 'faves', 'user')),
    #overlay_messages(),
    mark_external_request
)


#-------------------------------------------------------------------------------
# State
#-------------------------------------------------------------------------------

# AllanC - need to look into Pyramids security model
def is_admin(request):
    return request.session.get('admin',False)  # request.session['admin']

def is_comunity(request):
    return request.session.get('user',{}).get('approved', False)