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


Python settings.get函数代码示例

本文整理汇总了Python中uliweb.settings.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: init

    def init(self, project_dir, apps_dir):
        if not project_dir:
            project_dir = norm_path(os.path.join(apps_dir, '..'))
        
        Dispatcher.project_dir = project_dir
        Dispatcher.apps_dir = norm_path(os.path.join(project_dir, 'apps'))
        Dispatcher.apps = get_apps(self.apps_dir, self.include_apps, self.settings_file, self.local_settings_file)
        Dispatcher.modules = self.collect_modules()

        self.install_settings(self.modules['settings'])

        self.debug = settings.GLOBAL.get('DEBUG', False)

        #process global_objects
        self.install_global_objects()
        
        #process binds
        self.install_binds()
        
        dispatch.call(self, 'after_init_settings')
        
        Dispatcher.settings = settings
        
        #process domains
        self.process_domains(settings)
        
        #setup log
        self.set_log()
        
        #set app rules
        rules.set_app_rules(dict(settings.get('URL', {})))
        rules.set_urlroute_rules(dict(settings.get('URL_ROUTE', {})))

        Dispatcher.env = self._prepare_env()
        Dispatcher.template_dirs = self.get_template_dirs()
        Dispatcher.template_loader = self.install_template_loader(Dispatcher.template_dirs)

        #begin to start apps
        self.install_apps()
        dispatch.call(self, 'after_init_apps')
        #process views
        self.install_views(self.modules['views'])
        #process exposes
        self.install_exposes()
        #process middlewares
        Dispatcher.middlewares = self.install_middlewares()

        dispatch.call(self, 'prepare_default_env', Dispatcher.env)
        Dispatcher.default_template = pkg.resource_filename('uliweb.core', 'default.html')
        
        Dispatcher.installed = True
开发者ID:hb44,项目名称:uliweb,代码行数:51,代码来源:SimpleFrame.py

示例2: handle

    def handle(self, options, global_options, *args):
        from uliweb.utils.pyini import Ini
        from uliweb.utils.common import pkg
        from uliweb.contrib.template.tags import find
        from uliweb.contrib.staticfiles import url_for_static
        from uliweb import json_dumps
        import ConfigParser

        if not options.dest and not options.app:
            print "Error: Please use -d to specify output app"
            sys.exit(1)

        app = self.get_application(global_options)

        from uliweb import settings

        if options.dest:
            module = options.dest
            filename = pkg.resource_filename(options.dest, 'gulp_settings.ini')
        else:
            module = options.app
            filename = pkg.resource_filename(options.app, 'gulp_settings.ini')

        with open(filename, 'wb') as f:
            template_gulp = settings.get("TEMPLATE_GULP", {}) # 导出settings中的gulp配置
            template_use_keys = settings.get("TEMPLATE_USE", {}).keys() # 导出settings中的plugins的名字
            for dist,items in template_gulp.items():
                # 有序遍历gulp的concat配置
                item_dist = dist
                for name in items:
                    if name in template_use_keys:
                        # 如果plugins中有该插件则在ini中写入该配置
                        s = find(name)
                        m = s[0] + s[1]
                        f.write("[template_use." + name + "]\r\n")
                        for i in m:
                            if not i.startswith('<!--'):
                                f.write("toplinks[] = " + app.get_file(i, 'static') + "\r\n")
                        f.write("dist = " + item_dist + "\r\n")
                    f.write("\r\n")

        gulp_dist = pkg.resource_filename(module, '/static');
        gulp_settings = filename
        gulp_path = pkg.resource_filename("uliweb_ui","")
        import os
        terminal_command = "cd "+gulp_path+ " && gulp  --dist " + gulp_dist + " --settings " + gulp_settings
        print ">>> {}".format(terminal_command)
        os.system(terminal_command)
开发者ID:uliwebext,项目名称:uliweb-ui,代码行数:48,代码来源:commands.py

示例3: install_exposes

 def install_exposes(self):
     #EXPOSES format
     #endpoint = topic              #bind_name will be the same with function
     #expose_name = topic, func        
     #expose_name = topic, func, {args}
     d = settings.get('EXPOSES', {})
     for name, args in d.iteritems():
         if not args:
             continue
         is_wrong = False
         if isinstance(args, (tuple, list)):
             if len(args) == 2:
                 expose(args[0], name=name)(args[1])
             elif len(args) == 3:
                 if not isinstance(args[2], dict):
                     is_wrong = True
                 else:
                     expose(args[0], name=name, **args[2])(args[1])
             else:
                 is_wrong = True
         elif isinstance(args, (str, unicode)):
             expose(args)(name)
         else:
             is_wrong = True
         if is_wrong:
             log.error('EXPOSES definition should be "endpoint=url" or "name=url, endpoint" or "name=url, endpoint, {"args":value1,...}"')
             raise UliwebError('EXPOSES definition [%s=%r] is not right' % (name, args))
开发者ID:lssebastian,项目名称:uliweb,代码行数:27,代码来源:SimpleFrame.py

示例4: install_binds

 def install_binds(self):
     #process DISPATCH hooks
     #BINDS format
     #func = topic              #bind_name will be the same with function
     #bind_name = topic, func        
     #bind_name = topic, func, {args}
     d = settings.get('BINDS', {})
     for bind_name, args in d.iteritems():
         if not args:
             continue
         is_wrong = False
         if isinstance(args, (tuple, list)):
             if len(args) == 2:
                 dispatch.bind(args[0])(args[1])
             elif len(args) == 3:
                 if not isinstance(args[2], dict):
                     is_wrong = True
                 else:
                     dispatch.bind(args[0], **args[2])(args[1])
             else:
                 is_wrong = True
         elif isinstance(args, (str, unicode)):
             dispatch.bind(args)(bind_name)
         else:
             is_wrong = True
         if is_wrong:
             log.error('BINDS definition should be "function=topic" or "bind_name=topic, function" or "bind_name=topic, function, {"args":value1,...}"')
             raise UliwebError('BINDS definition [%s=%r] is not right' % (bind_name, args))
开发者ID:lssebastian,项目名称:uliweb,代码行数:28,代码来源:SimpleFrame.py

示例5: install_middlewares

 def install_middlewares(self):
     m = self._sort_middlewares(settings.get('MIDDLEWARES', {}).values())
     req_classes, res_classes, ex_classes = self._get_middlewares_classes(m)
     Dispatcher.process_request_classes = req_classes
     Dispatcher.process_response_classes = res_classes
     Dispatcher.process_exception_classes = ex_classes
     return m
开发者ID:bluesky4485,项目名称:uliweb,代码行数:7,代码来源:SimpleFrame.py

示例6: __init__

    def __init__(self, application, settings):
        from datetime import timedelta
        self.options = dict(settings.get('SESSION_STORAGE', {}))
        self.options['data_dir'] = application_path(self.options['data_dir'])
        if 'url' not in self.options:
            _url = (settings.get_var('ORM/CONNECTION', '') or
            settings.get_var('ORM/CONNECTIONS', {}).get('default', {}).get('CONNECTION', ''))
            if _url:
                self.options['url'] = _url
        
        #process Session options
        self.remember_me_timeout = settings.SESSION.remember_me_timeout
        self.session_storage_type = settings.SESSION.type
        self.timeout = settings.SESSION.timeout
        Session.force = settings.SESSION.force
        
        #process Cookie options
        SessionCookie.default_domain = settings.SESSION_COOKIE.domain
        SessionCookie.default_path = settings.SESSION_COOKIE.path
        SessionCookie.default_secure = settings.SESSION_COOKIE.secure
        SessionCookie.default_cookie_id = settings.SESSION_COOKIE.cookie_id

        if isinstance(settings.SESSION_COOKIE.timeout, int):
            timeout = timedelta(seconds=settings.SESSION_COOKIE.timeout)
        else:
            timeout = settings.SESSION_COOKIE.timeout
        SessionCookie.default_expiry_time = timeout
开发者ID:28sui,项目名称:uliweb,代码行数:27,代码来源:middle_session.py

示例7: after_init_apps

def after_init_apps(sender):
    import mimetypes
    from uliweb import settings
    
    for k, v in settings.get('MIME_TYPES').items():
        if not k.startswith('.'):
            k = '.' + k
        mimetypes.add_type(v, k)
开发者ID:08haozi,项目名称:uliweb,代码行数:8,代码来源:__init__.py

示例8: init_static_combine

def init_static_combine():
    """
    Process static combine, create md5 key according each static filename
    """
    from uliweb import settings
    from hashlib import md5
    import os
    
    d = {}
    for k, v in settings.get('STATIC_COMBINE', {}).items():
        key = '_cmb_'+md5(''.join(v)).hexdigest()+os.path.splitext(v[0])[1]
        d[key] = v
        
    return d
开发者ID:08haozi,项目名称:uliweb,代码行数:14,代码来源:__init__.py

示例9: init

    def init(self, project_dir, apps_dir):
        if not project_dir:
            project_dir = norm_path(os.path.join(apps_dir, ".."))
        Dispatcher.project_dir = project_dir
        Dispatcher.apps_dir = norm_path(os.path.join(project_dir, "apps"))
        Dispatcher.apps = get_apps(self.apps_dir, self.include_apps, self.settings_file, self.local_settings_file)
        Dispatcher.modules = self.collect_modules()

        self.install_settings(self.modules["settings"])

        # process global_objects
        self.install_global_objects()

        # process binds
        self.install_binds()

        dispatch.call(self, "after_init_settings")

        Dispatcher.settings = settings

        # process domains
        self.process_domains(settings)

        # setup log
        self.set_log()

        # set app rules
        rules.set_app_rules(dict(settings.get("URL", {})))

        Dispatcher.env = self._prepare_env()
        Dispatcher.template_dirs = self.get_template_dirs()
        Dispatcher.template_processors = {}
        self.install_template_processors()

        # begin to start apps
        self.install_apps()
        dispatch.call(self, "after_init_apps")
        # process views
        self.install_views(self.modules["views"])
        # process exposes
        self.install_exposes()
        # process middlewares
        Dispatcher.middlewares = self.install_middlewares()

        self.debug = settings.GLOBAL.get("DEBUG", False)
        dispatch.call(self, "prepare_default_env", Dispatcher.env)
        Dispatcher.default_template = pkg.resource_filename("uliweb.core", "default.html")

        Dispatcher.installed = True
开发者ID:biluo1989,项目名称:uliweb,代码行数:49,代码来源:SimpleFrame.py

示例10: after_init_apps

def after_init_apps(sender):

    # set workflow engine to load spec from database
    LOG.info(" * Initialize CoreWFManager with database storage")
    from redbreast.core.spec import CoreWFManager
    from redbreast.core.spec import WFDatabaseStorage
    from uliweb import settings
    storage = WFDatabaseStorage()
    CoreWFManager.set_storage(storage)

    bindable = settings.get_var('REDBREAST/ENABLE_EVENT_BIND', True)
    if bindable:
        LOG.info(" * Setup EVENT_BIND for CoreWFManage")
        from redbreast.core.spec import CoreWFManager, WFManagerBindPlugin
        plugin = WFManagerBindPlugin()
        d = settings.get('REDBREAST_BINDS', {})
        for bind_name, args in d.items():
            plugin.bind(args[0], args[1], args[2])

        CoreWFManager.register_plugin(plugin)
开发者ID:chu888chu888,项目名称:Python--uliweb-redbreast,代码行数:20,代码来源:__init__.py

示例11: get_session

def get_session(key=None):
    options = dict(settings.get('SESSION_STORAGE', {}))
    options['data_dir'] = application_path(options['data_dir'])
    if 'url' not in options:
        _url = (settings.get_var('ORM/CONNECTION', '') or
        settings.get_var('ORM/CONNECTIONS', {}).get('default', {}).get('CONNECTION', ''))
        if _url:
            options['url'] = _url

    #process Session options
    session_storage_type = settings.SESSION.type
    Session.force = settings.SESSION.force

    serial_cls_path = settings.SESSION.serial_cls
    if serial_cls_path:
        serial_cls = import_attr(serial_cls_path)
    else:
        serial_cls = None

    session = Session(key, storage_type=session_storage_type,
        options=options, expiry_time=settings.SESSION.timeout, serial_cls=serial_cls)
    return session
开发者ID:wangjun,项目名称:shapps,代码行数:22,代码来源:views.py

示例12: install_middlewares

 def install_middlewares(self):
     return self.sort_middlewares(settings.get('MIDDLEWARES', {}).values())
开发者ID:lssebastian,项目名称:uliweb,代码行数:2,代码来源:SimpleFrame.py

示例13: process_panel

def process_panel():
    p = settings.get('PANEL', {})
    for data in p.items():
        panel(**data).save()
开发者ID:uliwebext,项目名称:uliweb-peafowl,代码行数:4,代码来源:dashboardinit.py

示例14: process_layout

def process_layout():
    l = settings.get('PANELLAYOUT', {})
    for data in l.items():
        layout(**data).save()
开发者ID:uliwebext,项目名称:uliweb-peafowl,代码行数:4,代码来源:dashboardinit.py

示例15: process_dashboard

def process_dashboard():
    d = settings.get('DASHBOARD', {})
    for name, layout in d.items():
        data = {'name': name, 'layout': layout}
        dashboard(**data).save()
开发者ID:naomhan,项目名称:uliweb-peafowl,代码行数:5,代码来源:dashboardinit.py


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