当前位置: 首页>>代码示例>>Python>>正文


Python ConfigManager.getConfig方法代码示例

本文整理汇总了Python中shimehari.configuration.ConfigManager.getConfig方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigManager.getConfig方法的具体用法?Python ConfigManager.getConfig怎么用?Python ConfigManager.getConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在shimehari.configuration.ConfigManager的用法示例。


在下文中一共展示了ConfigManager.getConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: csrfProtect

# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import getConfig [as 别名]
    def csrfProtect(self, requestToken=None):
        if shared._csrfExempt:
            return

        if not request.method in ['POST', 'PUT', 'PATCH', 'DELETE']:
            return

        sessionToken = session.get('_csrfToken', None)
        if not sessionToken:
            # CSRF token missing
            abort(403)

        config = ConfigManager.getConfig()
        secretKey = config['SECRET_KEY']

        hmacCompare = hmac.new(secretKey, str(sessionToken).encode('utf-8'), digestmod=sha1)
        token = requestToken if requestToken is not None else request.form.get('_csrfToken')

        if hmacCompare.hexdigest() != token:
            # invalid CSRF token
            if self.csrfHandler:
                self.csrfHandler(*self.app.matchRequest())
            else:
                abort(403)

        if not self.checkCSRFExpire(token):
            # CSRF token expired
            abort(403)
开发者ID:glassesfactory,项目名称:Shimehari,代码行数:30,代码来源:crypt.py

示例2: get

# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import getConfig [as 别名]
 def get(self, sid):
     if not self.is_valid_key(sid):
         return self.new()
     config = ConfigManager.getConfig()
     secretKey = config['SECRET_KEY']
     if secretKey is not None:
         return self.session_class.load_cookie(request, key=self.key, secret_key=secretKey, sid=sid)
开发者ID:glassesfactory,项目名称:Shimehari,代码行数:9,代码来源:session.py

示例3: handle

# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import getConfig [as 别名]
    def handle(self, moduleType, name, *args, **options):
        if not moduleType == 'controller':
            raise CommandError('ない')

        path = options.get('path')
        if path is None:
            currentPath = os.getcwd()
            try:
                importFromString('config')
            except:
                sys.path.append(os.getcwd())
                try:
                    importFromString('config')
                except ImportError:
                    raise CommandError('config file is not found...')
            config = ConfigManager.getConfig(getEnviron())
            path = os.path.join(currentPath, config['APP_DIRECTORY'], config['CONTROLLER_DIRECTORY'])

        if not os.path.isdir(path):
            raise CommandError('Given path is invalid')

        ctrlTemplate = os.path.join(shimehari.__path__[0], 'core', 'conf', 'controller_template.org.py')

        name, filename = self.filenameValidation(path, name)
        newPath = os.path.join(path, filename)

        self.readAndCreateFileWithRename(ctrlTemplate, newPath, name)
开发者ID:Epictetus,项目名称:Shimehari,代码行数:29,代码来源:generate.py

示例4: run

# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import getConfig [as 别名]
    def run(self, *args, **options):
        import config

        # try:
        #     #humu-
        #     import config
        # except ImportError, e:
        #     sys.path.append(os.getcwd())
        #     try:
        #         import config
        #     except ImportError, e:
        #         t = sys.exc_info()[2]
        #         raise DrinkError(u'ちょっと頑張ったけどやっぱりコンフィグが見当たりません。\n%s' % e), None, traceback.print_exc(t)

        try:
            currentEnv = options.get('SHIMEHARI_ENV')
            currentConfig = ConfigManager.getConfig(currentEnv or 'development')
            app = importFromString( currentConfig['MAIN_SCRIPT'] + '.' + currentConfig['APP_INSTANCE_NAME'])

            if options.get('browser'):
                timer = threading.Timer(0.5, self.openBrowser, args=[self.host, self.port])
                timer.start()

            app.run(host=self.host, port=int(self.port), debug=True)

        except:
            raise
开发者ID:matsumos,项目名称:toodooo,代码行数:29,代码来源:ds.py

示例5: __init__

# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import getConfig [as 别名]
    def __init__(self, storetype=None):
        config = ConfigManager.getConfig(getEnviron())

        if config['CACHE_STORE'] is not None:
            store = config['CACHE_STORE']
        else:
            store = storetype

        self.store = self._importCacheStore(store)
开发者ID:Epictetus,项目名称:Shimehari,代码行数:11,代码来源:cache.py

示例6: _importCacheStore

# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import getConfig [as 别名]
 def _importCacheStore(self, storetype):
     if storetype == 'simple':
         return SimpleCacheStore()
     if storetype == 'memcache':
         return MemcachedCacheStore()
     if storetype == 'file':
         config = ConfigManager.getConfig(getEnviron())
         return FileSystemCacheStore(cacheDir=config['CACHE_DIR'])
     if storetype == 'redis':
         return RedisCacheStore()
     return NullCacheStore()
开发者ID:Epictetus,项目名称:Shimehari,代码行数:13,代码来源:cache.py

示例7: generateCSRFToken

# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import getConfig [as 别名]
def generateCSRFToken():
    if not '_csrfToken' in session:
        session['_csrfToken'] = genereateToken()

    now = datetime.datetime.now() + datetime.timedelta()
    session['_csrfTokenAdded'] = time.mktime(now.timetuple())

    config = ConfigManager.getConfig()
    secretKey = config['SECRET_KEY']

    hmacCsrf = hmac.new(secretKey, str(session['_csrfToken']).encode('utf-8'), digestmod=sha1)
    return hmacCsrf.hexdigest()
开发者ID:glassesfactory,项目名称:Shimehari,代码行数:14,代码来源:crypt.py

示例8: handle

# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import getConfig [as 别名]
    def handle(self, *args, **options):
        try:
            importFromString('config')
        except ImportError:
            sys.path.append(os.getcwd())
            try:
                importFromString('config')
            except ImportError:
                raise CommandError(u'コンフィグファイルが見当たりません')

        env = options.get('env')
        if env is None:
            env = 'development'

        sys.stdout.write('\nYour Shimehari App Current Config.\n\n')
        sys.stdout.write('-------------------------------------------------\n')
        sys.stdout.write(ConfigManager.getConfig(env).dump())
        sys.stdout.write('\n')
开发者ID:Epictetus,项目名称:Shimehari,代码行数:20,代码来源:checkconfig.py

示例9: __init__

# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import getConfig [as 别名]
    def __init__(self, importName, appFolder='app',
                  controllerFolder='controllers', viewFolder=None):
        self.importName = importName
        self.currentEnv = getEnviron()

        self.rootPath = getRootPath(self.importName)

        from shimehari.configuration import ConfigManager
        config = ConfigManager.getConfig(self.currentEnv)

        if config and self.rootPath == os.getcwd() + '/' + config['APP_DIRECTORY']:
            self.rootPath = os.getcwd()

        self.appFolder = config['APP_DIRECTORY'] if config and config['APP_DIRECTORY'] else appFolder
        self.controllerFolder = config['CONTROLLER_DIRECTORY'] if config and \
                                config['CONTROLLER_DIRECTORY'] else controllerFolder
        self.viewFolder = config['VIEW_DIRECTORY'] if config and config['VIEW_DIRECTORY'] else viewFolder

        self._staticFolders = {}
        if config and config['ASSETS_DIRECTORY']:
            assetsDir = config['ASSETS_DIRECTORY']
            if type(assetsDir) is list:
                [self._staticFolders.setdefault(x, x) for x in assetsDir]
            else:
                self._staticFolders = {assetsDir: assetsDir}

        if config and config['STATIC_DIRECTORY']:
            staticDir = config['STATIC_DIRECTORY']
            if isinstance(staticDir, (list, tuple)):
                [self._staticFolders.setdefault(x, x) for x in staticDir]
            elif isinstance(staticDir, dict):
                self._staticFolders.update(staticDir)
            else:
                self._staticFolders.setdefault(staticDir, staticDir)
        self._staticURLDict = {}

        def _assetsURL(self):
            if config['ASSETS_DIRECTORY'] in self._staticFolders:
                return self.getStaticURL(config['ASSETS_DIRECTORY'])
            else:
                return None
        self.assetsURL = property(_assetsURL)
        del _assetsURL
开发者ID:glassesfactory,项目名称:Shimehari,代码行数:45,代码来源:helpers.py

示例10: __init__

# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import getConfig [as 别名]
    def __init__(self, importName, appFolder='app',
                  controllerFolder='controllers', viewFolder=None):
        self.importName = importName
        self.currentEnv = getEnviron()

        self.rootPath = getRootPath(self.importName)

        from shimehari.configuration import ConfigManager
        config = ConfigManager.getConfig(self.currentEnv)

        if config and self.rootPath == os.getcwd() + '/' + config['APP_DIRECTORY']:
            self.rootPath = os.getcwd()

        self.appFolder = config['APP_DIRECTORY'] if config and config['APP_DIRECTORY'] else appFolder
        self.controllerFolder = config['CONTROLLER_DIRECTORY'] if config and \
                                config['CONTROLLER_DIRECTORY'] else controllerFolder
        self.viewFolder = config['VIEW_DIRECTORY'] if config and config['VIEW_DIRECTORY'] else viewFolder

        self._staticFolder = config['ASSETS_DIRECTORY'] if config and config['ASSETS_DIRECTORY'] else None
        self._staticURL = None
开发者ID:Epictetus,项目名称:Shimehari,代码行数:22,代码来源:helpers.py

示例11: createLogger

# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import getConfig [as 别名]
def createLogger(loggerName='shimehariLoagger'):

    Logger = getLoggerClass()

    class DebugLogger(Logger):
        def getEffectiveLevel(x):
            if x.level == 0 and config['DEBUG']:
                return DEBUG
            return Logger.getEffectiveLevel(x)

    class DebugHandler(StreamHandler):
        def emit(x, record):
            StreamHandler.emit(x, record) if config['DEBUG'] else None
    config = ConfigManager.getConfig(getEnviron())
    if config['LOG_FILE_OUTPUT']:
        fn = os.path.join(config['LOG_FILE_DIRECTORY'], getEnviron()) + '.log'
        if config['LOG_FILE_ROTATE']:
            from logging import RotateFileHandler
            handler = RotateFileHandler(fn, 'a', config['LOG_ROTATE_MAX_BITE'], config['LOG_ROTATE_COUNT'])
        else:
            from logging import FileHandler
            handler = FileHandler(fn, 'a')

        handler.setFormatter(Formatter(config['LOG_OUTPUT_FORMAT']))
        logger = getLogger()
    else:
        handler = DebugHandler()
        handler.setFormatter(Formatter(config['LOG_DEBUG_FORMAT']))
        logger = getLogger(loggerName)

    logger.setLevel(DEBUG)

    del logger.handlers[:]
    logger.__class__ = DebugLogger
    logger.addHandler(handler)
    return logger
开发者ID:Epictetus,项目名称:Shimehari,代码行数:38,代码来源:logging.py

示例12: new

# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import getConfig [as 别名]
 def new(self):
     config = ConfigManager.getConfig()
     secretKey = config['SECRET_KEY']
     if secretKey is not None:
         return self.session_class.load_cookie(request, key=self.key, secret_key=secretKey)
开发者ID:glassesfactory,项目名称:Shimehari,代码行数:7,代码来源:session.py

示例13: getCookieExpire

# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import getConfig [as 别名]
 def getCookieExpire(self, session):
     if session.permanent:
         return datetime.utcnow() + ConfigManager.getConfig()['PERMANENT_SESSION_LIFETIME']
开发者ID:glassesfactory,项目名称:Shimehari,代码行数:5,代码来源:session.py

示例14: getCookieSecure

# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import getConfig [as 别名]
 def getCookieSecure(self):
     return ConfigManager.getConfig()['SESSION_COOKIE_SECURE']
开发者ID:glassesfactory,项目名称:Shimehari,代码行数:4,代码来源:session.py

示例15: getCookieHttpOnly

# 需要导入模块: from shimehari.configuration import ConfigManager [as 别名]
# 或者: from shimehari.configuration.ConfigManager import getConfig [as 别名]
 def getCookieHttpOnly(self):
     return ConfigManager.getConfig()['SESSION_COOKIE_HTTPONLY']
开发者ID:glassesfactory,项目名称:Shimehari,代码行数:4,代码来源:session.py


注:本文中的shimehari.configuration.ConfigManager.getConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。