def is_debug(): default = True """The cache time""" debug_value_cache_time = get_config(u'debug_value_cache_time', default=60, cache_time=3600) debug = get_config(u'debug', default=default, cache_time=debug_value_cache_time) return debug if debug in (True, False) else default
def prepare(cls): for name,row in get_config(u'defaults', u'variables', flush_memcache=True, default=[]): #instantiate the entity try: var = var_cache.set(name, row) except Exception, e: logging.error(u"Error while creating entity of kind '%s'. MSG: %s" % (cls.__name__, e))
def load_route_map(): # init route map route_map = Mapper(explicit=True) #setup all routes from the routes config for route in get_config(u'routes', u'routes', flush_memcache=True, default=[]): kwargs = route[2][u'kwargs'] if route[2].get(u'kwargs') else {} route_map.connect(route[0], route[1], controller=route[2][u'controller'], action=route[2][u'action'], **kwargs) return route_map
def event_keys(): conf = get_config(u'events', default={}) return conf.keys()
def event_codes(): conf = get_config(u'events', default={}) return conf.values()
def base_url(): return get_config(u'base_url')
def event_code(event): conf = get_config(u'events', default={}) try: return conf[event] except KeyError: return None
#!/usr/bin/env python # -*- coding: utf-8 -*- import os, sys, random, string, array, logging import urllib2,urllib import base64 import bolognium.lib.aes as aes from bolognium.ext.config import get_config key = get_config(u'aes_key') # u'TisG!7nrPMb8S3&QnyHSJT@?LEr7hAmv' iv = get_config(u'aes_iv') # u'BsKzU5QkqC5d4Gvn' def encrypt(string): """Encrypts the string with key and iv above""" return base64.b64encode(encryptData(key, iv, string)) def decrypt(string): """Decrypts the string with key and iv above""" return decryptData(key, iv, base64.b64decode(string)) def encryptData(key, iv, data, mode=aes.AESModeOfOperation.modeOfOperation["CFB"]): """encrypt `data` using `key` `key` should be a string of bytes. returned cipher is a string of bytes prepended with the initialization vector. """ key = map(ord, key)