• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python config.get_cfg_storage函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: update

    def update(self):
        data = []

        fields = config.get_cfg_storage(FIELD_ID)
        previews = config.get_cfg_storage(PREVIEW_ID)

        for name, cls in fields.items():
            data.append({'name': name,
                         'doc': cls.__doc__,
                         'preview': previews.get(cls)})

        data.sort()
        self.fields = data
开发者ID:WouterVH,项目名称:ptah,代码行数:13,代码来源:fields.py


示例2: run

    def run(self):
        # print defaults
        if self.options.printcfg:
            data = config.get_cfg_storage(SETTINGS_OB_ID).export(True)

            parser = configparser.ConfigParser(dict_type=OrderedDict)
            for key, val in sorted(data.items()):
                parser.set(configparser.DEFAULTSECT,
                           key, val.replace('%', '%%'))

            fp = NativeIO()
            try:
                parser.write(fp)
            finally:
                pass

            print (fp.getvalue())
            return

        if self.options.all:
            section = ''
        else:
            section = self.options.section

        # print description
        groups = sorted(config.get_cfg_storage(ID_SETTINGS_GROUP).items(),
                        key = lambda item: item[1].__title__)

        for name, group in groups:
            if section and name != section:
                continue

            print ('')
            title = group.__title__ or name

            print (grpTitleWrap.fill('{0} ({1})'.format(title, name)))
            if group.__description__:
                print (grpDescriptionWrap.fill(
                    group.__description__))

            print ('')
            for node in group.__fields__.values():
                default = '<required>' if node.required else node.default
                print (nameWrap.fill(
                    ('%s.%s: %s (%s: %s)' % (
                        name, node.name, node.title,
                        node.__class__.__name__, default))))

                print (nameTitleWrap.fill(node.description))
                print ('')
开发者ID:carlicos,项目名称:ptah,代码行数:50,代码来源:settings.py


示例3: test_rest_registerService_apidoc

    def test_rest_registerService_apidoc(self):
        from ptahcms import restsrv

        restsrv.RestService('test', 'Test service')
        self.init_ptah()

        srv = config.get_cfg_storage(restsrv.ID_REST)['test']

        @srv.action('action', 'Action')
        def raction(request, *args):
            """ doc string """

        self.assertIn('apidoc', srv.actions)

        info = srv(self.make_request(), 'apidoc')

        self.assertEqual(info['name'], 'test')
        self.assertEqual(info['title'], 'Test service')
        self.assertEqual(len(info['actions']), 2)

        self.assertEqual(info['actions'][0]['name'], 'apidoc')
        self.assertEqual(
            info['actions'][0]['__link__'], 'http://example.com/apidoc')
        self.assertEqual(info['actions'][1]['name'], 'action')
        self.assertEqual(
            info['actions'][1]['__link__'], 'http://example.com/action')
开发者ID:djedproject,项目名称:ptahcms,代码行数:26,代码来源:test_restsrv.py


示例4: __init__

    def __init__(self, name, title, description='',
                 prefix='role:', system=False):
        id = '%s%s' % (prefix, name)

        self.id = id
        self.name = name
        self.title = title
        self.description = description
        self.system = system

        self.allowed = set()
        self.denied = set()

        # conflict detection and introspection
        info = config.DirectiveInfo()

        discr = (ID_ROLE, name)
        intr = config.Introspectable(ID_ROLE, discr, title, ID_ROLE)
        intr['role'] = self
        intr['codeinfo'] = info.codeinfo

        info.attach(
            config.Action(
                lambda config, r: \
                    config.get_cfg_storage(ID_ROLE).update({r.name: r}),
                (self, ), discriminator=discr, introspectables=(intr,))
            )
开发者ID:webmaven,项目名称:ptah,代码行数:27,代码来源:security.py


示例5: list_types

    def list_types(self, container):
        if container.__type__ is not self or \
               not isinstance(container, BaseContainer):
            return ()

        types = []
        all_types = config.get_cfg_storage(TYPES_DIR_ID)

        if self.filter_content_types:
            allowed_types = self.allowed_content_types
            if callable(allowed_types):
                allowed_types = allowed_types(container)

            for tinfo in allowed_types:
                if isinstance(tinfo, string_types):
                    tinfo = all_types.get('cms-type:%s'%tinfo)

                if tinfo and tinfo.is_allowed(container):
                    types.append(tinfo)
        else:
            for tinfo in all_types.values():
                if tinfo.global_allow and tinfo.is_allowed(container):
                    types.append(tinfo)

        return types
开发者ID:runyaga,项目名称:ptah,代码行数:25,代码来源:tinfo.py


示例6: register_settings

def register_settings(name, *fields, **kw):
    """ register settings group """
    iname = name
    for ch in ('.', '-'):
        iname = iname.replace(ch, '_')

    category = InterfaceClass(
        'SettingsGroup:%s' % iname.upper(), (),
        __doc__='Settings group: %s' % name,
        __module__='ptah.config.settings')

    for field in fields:
        field.required = False
        if field.default is form.null:
            raise StopException(
              'Default value is required for "{0}.{1}"'.format(name,field.name))

    group = Group(name=name, *fields, **kw)
    interface.directlyProvides(Group, category)

    info = config.DirectiveInfo()
    discr = (ID_SETTINGS_GROUP, name)
    intr = config.Introspectable(
        ID_SETTINGS_GROUP, discr, group.__title__, ID_SETTINGS_GROUP)
    intr['name'] = name
    intr['group'] = group
    intr['codeinfo'] = info.codeinfo

    info.attach(
        config.Action(
            lambda config, group: config.get_cfg_storage(ID_SETTINGS_GROUP)\
                .update({group.__name__: group.clone(config.registry)}),
            (group,), discriminator=discr, introspectables=(intr,))
        )
开发者ID:runyaga,项目名称:ptah,代码行数:34,代码来源:settings.py


示例7: getInfo

    def getInfo(self, action):
        factory, ifaces = action.args[1:]
        factoryInfo = '%s.%s'%(action.info.module.__name__, factory.__name__)

        if len(action.args[2]) > 1:
            obj = action.args[2][0]
            klass = action.args[2][-1]
            event = config.get_cfg_storage(directives.EVENT_ID).get(
                action.args[2][-1], None)
        else:
            obj = None
            klass = action.args[2][0]
            event = config.get_cfg_storage(directives.EVENT_ID).get(
                action.args[2][0], None)

        return locals()
开发者ID:WouterVH,项目名称:ptah,代码行数:16,代码来源:introspect.py


示例8: update

    def update(self):
        ev = self.request.params.get('ev')

        all_events = config.get_cfg_storage(directives.EVENT_ID)
        self.event = event = all_events.get(ev)

        if event is None:
            events = []
            for n, ev in all_events.items():
                if isinstance(n, basestring):
                    events.append((ev.title, ev))

            events.sort()
            self.events = [ev for _t, ev in events]
        else:
            pkgs = list_packages()
            evinst = event.instance

            seen = set()
            actions = []
            for pkg in pkgs:
                for action in directives.scan(pkg, seen, exclude):
                    if action.discriminator[0] == 'ptah.config:subscriber':
                        required = action.args[2]
                        if len(required) == 2 and required[1] == evinst:
                            actions.append(action)
                        elif required[0] == evinst:
                            actions.append(action)

            self.actions = actions
开发者ID:WouterVH,项目名称:ptah,代码行数:30,代码来源:introspect.py


示例9: authenticate

    def authenticate(self, credentials):
        providers = config.get_cfg_storage(AUTH_PROVIDER_ID)
        for pname, provider in providers.items():
            principal = provider.authenticate(credentials)
            if principal is not None:
                info = AuthInfo(principal)

                for checker in \
                        config.get_cfg_storage(AUTH_CHECKER_ID).values():
                    if not checker(info):
                        return info

                info.status = True
                return info

        return AuthInfo(None)
开发者ID:runyaga,项目名称:ptah,代码行数:16,代码来源:authentication.py


示例10: pyramid_auth_provider

def pyramid_auth_provider(config, name, provider):
    """ pyramid configurator directive for
    authentication provider registration::

       class AuthProvider(object):
           ...

       config = Configurator()
       config.include('ptah')
       config.ptah_auth_provider('my-provider', AuthProvider())
    """
    info = ptah.config.DirectiveInfo()
    discr = (AUTH_PROVIDER_ID, name)
    intr = ptah.config.Introspectable(
        AUTH_PROVIDER_ID, discr, name, AUTH_PROVIDER_ID)
    intr['id'] = name
    intr['name'] = '{0}.{1}'.format(
        info.codeinfo.module, provider.__class__.__name__)
    intr['provider'] = provider
    intr['codeinfo'] = info.codeinfo

    config.action(
        discr,
        lambda config, n, p: \
            config.get_cfg_storage(AUTH_PROVIDER_ID).update({n: p}),
        (config, name, provider), introspectables=(intr,))
开发者ID:runyaga,项目名称:ptah,代码行数:26,代码来源:authentication.py


示例11: render_includes

def render_includes(request):
    _libraries = config.get_cfg_storage(LIBRARY_ID)

    seen = set()
    libraries = []

    libs = getattr(request, '__includes', None)
    if libs is None:
        return u''

    def _process(l_id):
        lib = _libraries.get(l_id)
        if lib is None:
            seen.add(l_id)
            return

        for require in lib.require:
            if require not in seen:
                _process(require)

        seen.add(l_id)
        libraries.append(lib)

    for id in libs:
        if id not in seen:
            _process(id)

    return u'\n'.join(lib.render(request) for lib in libraries)
开发者ID:WouterVH,项目名称:ptah,代码行数:28,代码来源:library.py


示例12: auth_checker

def auth_checker(checker, __cfg=None, __depth=1):
    """Register authentication checker. Checker function accepts
    :py:class:`ptah.authentication.AuthInfo` object.

    :param checker: Checker function.

    Checker function interface :py:func:`ptah.interfaces.auth_checker`

    .. code-block:: python

      @ptah.auth_checker
      def my_checker(info):
          ...

    """
    info = config.DirectiveInfo(__depth)
    discr = (AUTH_CHECKER_ID, hash(checker))
    intr = config.Introspectable(
        AUTH_CHECKER_ID, discr, checker.__name__, AUTH_CHECKER_ID)
    intr['name'] = '{0}.{1}'.format(info.codeinfo.module, checker.__name__)
    intr['callable'] = checker
    intr['codeinfo'] = info.codeinfo

    info.attach(
        config.Action(
            lambda config, checker: config.get_cfg_storage(AUTH_CHECKER_ID)\
                .update({id(checker): checker}),
            (checker,), discriminator=discr, introspectables=(intr,)),
        __cfg)
    return checker
开发者ID:webmaven,项目名称:ptah,代码行数:30,代码来源:authentication.py


示例13: render_includes

def render_includes(request):
    """
    Renders HTML for all included libraries for this request.

    :param request: Pyramid request
    """
    _libraries = config.get_cfg_storage(LIBRARY_ID)

    seen = set()
    libraries = []

    libs = getattr(request, '__includes', None)
    if libs is None:
        return ''

    def _process(l_id):
        lib = _libraries.get(l_id)
        if lib is None:
            seen.add(l_id)
            return

        for require in lib.require:
            if require not in seen:
                _process(require)

        seen.add(l_id)
        libraries.append(lib)

    for id in libs:
        if id not in seen:
            _process(id)

    return '\n'.join(lib.render(request) for lib in libraries)
开发者ID:runyaga,项目名称:ptah,代码行数:33,代码来源:library.py


示例14: register_type_impl

def register_type_impl(
    config, cls, tinfo, name, fieldset=None, fieldNames=None, **kw):

    # generate schema
    fieldset = kw.get('fieldset')
    if fieldset is None:
        kw['fieldset'] = ptah.generate_fieldset(
            cls, fieldNames=fieldNames, namesFilter=names_filter)
        log.info("Generating fieldset for %s content type.", cls)

    if 'global_allow' not in kw and not issubclass(cls, Content):
        kw['global_allow'] = False

    tinfo.__dict__.update(kw)

    tinfo.cls = cls

    config.get_cfg_storage(TYPES_DIR_ID)[tinfo.__uri__] = tinfo

    # sql query for content resolver
    cls.__uri_sql_get__ = ptah.QueryFreezer(
        lambda: ptah.get_session().query(cls) \
            .filter(cls.__uri__ == sqla.sql.bindparam('uri')))

    # build cms actions
    build_class_actions(cls)
开发者ID:djedproject,项目名称:ptahcms,代码行数:26,代码来源:tinfo.py


示例15: test_rest_registerService_apidoc

    def test_rest_registerService_apidoc(self):
        import ptah.rest

        ptah.rest.RestService('test', 'Test service')
        self._init_ptah()

        srv = config.get_cfg_storage(ptah.rest.REST_ID)['test']

        @srv.action('action', 'Action')
        def raction(request, *args):
            """ doc string """

        self.assertIn('apidoc', srv.actions)

        info = srv(self._makeRequest(), 'apidoc')

        self.assertEqual(info['name'], 'test')
        self.assertEqual(info['title'], 'Test service')
        self.assertEqual(len(info['actions']), 2)

        self.assertEqual(info['actions'][0]['name'], 'apidoc')
        self.assertEqual(
            info['actions'][0]['__link__'], 'http://localhost:8080/apidoc')
        self.assertEqual(info['actions'][1]['name'], 'action')
        self.assertEqual(
            info['actions'][1]['__link__'], 'http://localhost:8080/action')
开发者ID:WouterVH,项目名称:ptah,代码行数:26,代码来源:test_rest.py


示例16: __iter__

 def __iter__(self):
     acls = config.get_cfg_storage(ACL_ID)
     for aname in self.acls:
         acl = acls.get(aname)
         if acl is not None:
             for rec in acl:
                 yield rec
开发者ID:WouterVH,项目名称:ptah,代码行数:7,代码来源:security.py


示例17: get_types

def get_types():
    """ Get all registered types.

    :Returns:
      - mapping of all registered identifier and TypeInformation
    """
    return config.get_cfg_storage(TYPES_DIR_ID)
开发者ID:carlicos,项目名称:ptah,代码行数:7,代码来源:typeinfo.py


示例18: test_rest_api_auth

    def test_rest_api_auth(self):
        from ptah.rest import Api, Login
        from ptah import authentication
        self._init_ptah()

        config.get_cfg_storage(
            authentication.AUTH_PROVIDER_ID)['test'] = Provider()

        request = DummyRequest(params = {'login': 'admin', 'password': '12345'})

        login = Login(request)
        info = simplejson.loads(login.render())

        request = DummyRequest(environ = {'HTTP_X_AUTH_TOKEN': 'unknown'})
        request.matchdict = {'service': 'cms', 'subpath': ()}

        api = Api(request)
        api.render()
        self.assertEqual(ptah.authService.get_userid(), None)

        token = info['auth-token']

        request = DummyRequest(environ = {'HTTP_X_AUTH_TOKEN': token})
        request.matchdict = {'service': 'cms', 'subpath': ()}

        api = Api(request)
        api.render()
        self.assertEqual(ptah.authService.get_userid(), 'testprincipal:1')
开发者ID:WouterVH,项目名称:ptah,代码行数:28,代码来源:test_rest.py


示例19: get_principal_bylogin

    def get_principal_bylogin(self, login):
        providers = config.get_cfg_storage(AUTH_PROVIDER_ID)

        for pname, provider in providers.items():
            principal = provider.get_principal_bylogin(login)
            if principal is not None:
                return principal
开发者ID:WouterVH,项目名称:ptah,代码行数:7,代码来源:authentication.py


示例20: get_principal_byemail

    def get_principal_byemail(self, email):
        """ Return principal by email """
        providers = config.get_cfg_storage(AUTH_PROVIDER_ID)

        for pname, provider in providers.items():
            principal = provider.get_principal_byemail(email)
            if principal is not None:
                return principal
开发者ID:carlicos,项目名称:ptah,代码行数:8,代码来源:authentication.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python view.template函数代码示例发布时间:2022-05-25
下一篇:
Python config.cleanup_system函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap