# coding: utf-8 from pkg_resources import get_distribution from pyramid.httpexceptions import HTTPNotFound from pyramid.view import static_view from pyramid.view import view_config # www is a view for static files; it will be found when all other # views fail to be found (it's a NotFound view) www = static_view('hugitout:static', cache_max_age=86400) cache_one_hour = 3600 cache_one_day = 86400 never_cache = 0 @view_config(name='versions.json', renderer='json', http_cache=cache_one_hour) def versions(request): pjqm_dist = get_distribution('pyramid_jqm') pyramid_dist = get_distribution('pyramid') return {'pjqm_version':pjqm_dist.version, 'pyramid_version':pyramid_dist.version} @view_config(name='countries.json', renderer='json', http_cache=cache_one_day) def countries(request): return countrylist @view_config(name='webframeworks.json', renderer='json', http_cache=cache_one_day) def webframeworks(crequest): return webframework_list
from pyramid.config import Configurator #from pyramid.session import UnencryptedCookieSessionFactoryConfig from pyramid_beaker import session_factory_from_settings from pyramid.view import static_view from pyramid.renderers import JSON from sqlalchemy import engine_from_config from ddb.controller.map import map_include from ddb.controller.api import api_include from .models import ( DBSession, Base, ) ddb_static_view = static_view('ddb:static', use_subpath=True) def include_static(config): config.add_route("static", "/static/*subpath") config.add_view(ddb_static_view, route_name="static") def main(global_config, **settings): """ Returns Pyramid WSGI application. """ engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.bind = engine
from pyramid.config import Configurator #from pyramid.session import UnencryptedCookieSessionFactoryConfig from pyramid_beaker import session_factory_from_settings from pyramid.view import static_view from pyramid.renderers import JSON from sqlalchemy import engine_from_config from ddb.controller.map import map_include from ddb.controller.api import api_include from .models import ( DBSession, Base, ) ddb_static_view = static_view('ddb:static', use_subpath=True) def include_static(config): config.add_route("static", "/static/*subpath") config.add_view(ddb_static_view, route_name="static") def main(global_config, **settings): """ Returns Pyramid WSGI application. """ engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine)
from pyramid.renderers import render_to_response from pyramid.view import static_view from pyramid.view import view_config from pyramid_xmlrpc import xmlrpc_view from webob import Response from models import Server from logger import LOG try: from zopyx.smartprintng.authentication import authenticateRequest, authorizeRequest have_authentication = True except ImportError: from nullauth import authenticateRequest, authorizeRequest have_authentication = False static_view = static_view('templates/static', use_subpath=True) ################## # HTTP views ################## @view_config(for_=Server, request_method='GET', permission='read') class index(object): """ The default view providing some system information """ def __init__(self, context, request): self.context = context self.request = request def __call__(self):