def manager(accesses, zcml_file, users, clients, grants, tokens): # Read users config = ConfigParser.ConfigParser() config.read(accesses) admin_accesses = config.items('admin') # load crom monkey.incompat() implicit.initialize() # Grokking trigger load_zcml(zcml_file) @cooper.basicauth(users=admin_accesses, realm='TrilithAdmin') def admin_ui(environ, start_response): locale = get_environ_language(environ) or 'fr_FR' localizer = get_localizer(locale) with Locale(locale, localizer): request = Request(environ) root = Admin(users, clients, grants, tokens) response = PUBLISHER.publish(request, root, handle_errors=False) return response(environ, start_response) return admin_ui
async def prepare_crypto(app, loop): key = get_key('jwt.key') app.jwt_service = JWTService(key, JWTHandler, lifetime=600) # Bootstrapping the Crom registry monkey.incompat() implicit.initialize() # Configure configure(taels) configure(taels_demo) print('INITIALIZED !!')
# -*- coding: utf-8 -*- import os HERE = os.path.dirname(os.path.abspath(__file__)) # We setup the cache for Chameleon templates template_cache = os.path.join(HERE, 'cache') if not os.path.exists(template_cache): os.makedirs(template_cache) os.environ["CHAMELEON_CACHE"] = template_cache # Bootstrapping the Crom registry from crom import monkey, implicit monkey.incompat() implicit.initialize() # Read the ZCML # This is not a mandatory stage. # Actually, what the ZCML loading does is grok the packages # This can be done manually, using `crom.configure` from cromlech.configuration.utils import load_zcml load_zcml(os.path.join(HERE, 'app.zcml')) # Load translation # This is needed only if we want internationalization from cromlech.i18n import load_translations_directories load_translations_directories() # Adding the event dispatcher # Use only if you have event handlers or plan to have some.
def setup_function(method): monkey.incompat() implicit.initialize()
with Configuration('config.json') as config: # We setup the cache for Chameleon templates os.environ["CHAMELEON_CACHE"] = config['cache']['templates'] # We ask for the PO files to be compiled, # as we don't want to do it by hand os.environ["cromlech_compile_mo_files"] = "True" # We initialize our Crom registry # Here, we would have to "grok" our packages. # We can do it with a zcml file or manually. # We init it here, just to have the view lookup working. from crom import monkey, implicit monkey.incompat() # incompat means it changes the behavior of the iface implicit.initialize() # we create a new registry and make it the default # we define our publisher from cromlech.dawnlight import DawnlightPublisher from cromlech.browser.interfaces import IView from cromlech.dawnlight import ViewLookup, view_locator from cromlech.webob.request import Request def query_view(request, context, name=""): return IView.component(context, request, name=name) view_lookup = ViewLookup(view_locator(query_view)) Publisher = DawnlightPublisher(view_lookup=view_lookup) # We read the zodb conf and initialize it from cromlech.zodb import init_db_from_file
def setup_function(f): implicit.initialize()
# -*- coding: utf-8 -*- import os from loader import Configuration with Configuration('config.json') as config: # We setup the cache for Chameleon templates os.environ["CHAMELEON_CACHE"] = config['templates']['cache'] # Bootstrapping the Crom registry from crom import monkey, implicit monkey.incompat() implicit.initialize() # Getting the crypto key and creating the JWT service from cromlech.sessions.jwt import key_from_file from cromlech.sessions.jwt import JWTCookieSession key = key_from_file(config['session']['jwt_key']) session_wrapper = JWTCookieSession(key, int(config['session']['timeout'])) # read the ZCML from cromlech.configuration.utils import load_zcml load_zcml(config['app']['zcml']) # load translation from cromlech.i18n import load_translations_directories load_translations_directories() # Create the application, including the middlewares.