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


Python ptah.get_settings函数代码示例

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


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

示例1: initialized

def initialized(ev):
    PTAH = ptah.get_settings(ptah.CFG_ID_PTAH, ev.registry)

    # mail
    PTAH['Mailer'] = DummyMailer()
    PTAH['full_email_address'] = formataddr(
        (PTAH['email_from_name'], PTAH['email_from_address']))

    # sqla
    SQLA = ptah.get_settings(ptah.CFG_ID_SQLA, ev.registry)
    url = SQLA['url']
    if url:
        engine_args = {}
        if SQLA['cache']:
            cache = {}
            engine_args['execution_options'] = \
                {'compiled_cache': cache}
            SQLA['sqlalchemy_cache'] = cache
        try:
            engine = sqlahelper.get_engine()
        except: # pragma: no cover
            engine = sqlalchemy.engine_from_config(
                {'sqlalchemy.url': url}, 'sqlalchemy.', **engine_args)
            sqlahelper.add_engine(engine)

    # ptah manage
    if PTAH['manage']:
        ev.config.add_route(
            'ptah-manage', '/ptah-manage/*traverse',
            factory=ptah.manage.PtahManageRoute, use_global_views=True)
        ptah.manage.set_access_manager(
            ptah.manage.PtahAccessManager())
开发者ID:runyaga,项目名称:ptah,代码行数:32,代码来源:ptahsettings.py

示例2: initialized

def initialized(ev):
    global maintence
    PLOUD = ptah.get_settings("ploud", ev.registry)
    APACHE = ptah.get_settings("apache", ev.registry)
    if PLOUD["maintenance"]:
        maintence = Maintenance(APACHE["host"])
        logger.info("Maintenance worker has been started.")
    else:
        maintence = None
开发者ID:enfold,项目名称:ploud.utils,代码行数:9,代码来源:maintenance.py

示例3: send_activation

def send_activation(email, token):
    mail_template = renderers.get_renderer(
        'newui/validate_email.txt').implementation()

    MAIL = ptah.get_settings(ptah.CFG_ID_PTAH)
    FRONTEND = ptah.get_settings('frontend')

    data = dict(host=FRONTEND['host'], email=email, token=token)
    msg = MIMEText(str(mail_template(**data)))
    msg['Subject'] = 'Activate Your Ploud Account'
    msg['From'] = FRONTEND['email_from']
    msg['To'] = email

    MAIL['Mailer'].send(FRONTEND['email_from'], email, msg)
开发者ID:enfold,项目名称:ploud.frontend,代码行数:14,代码来源:signup.py

示例4: send_new_password_email

def send_new_password_email(email, token):
    MAIL = ptah.get_settings(ptah.CFG_ID_PTAH)
    FRONTEND = ptah.get_settings('frontend')

    data = dict(host=FRONTEND['host'], email=email, token=token)

    text = renderers.render('ploud.frontend:newui/reset_password.txt', data)

    msg = MIMEText(text.encode('utf-8'))
    msg['Subject'] = "You've Reset Your Ploud Password"
    msg['From'] = FRONTEND['email_from']
    msg['To'] = email

    MAIL['Mailer'].send(FRONTEND['email_from'], email, msg)
开发者ID:enfold,项目名称:ploud.frontend,代码行数:14,代码来源:login.py

示例5: create

    def create(self):
        data, errors = self.extract()

        if errors:
            self.message(errors, "form-error")
            return

        # create user
        cfg = ptah.get_settings(ptahcrowd.CFG_ID_CROWD, self.request.registry)
        tp = cfg["type"]
        if not tp.startswith("type:"):
            tp = "type:{0}".format(tp)

        tinfo = ptah.resolve(tp)

        user = tinfo.create(
            name=data["name"],
            login=data["login"],
            email=data["login"],
            validated=data["validated"],
            suspended=data["suspended"],
        )
        user.password = ptah.pwd_tool.encode(data["password"])

        tinfo.add(user)

        # notify system
        self.request.registry.notify(ptah.events.PrincipalAddedEvent(user))

        self.message("User has been created.", "success")
        return HTTPFound(location=".")
开发者ID:webmaven,项目名称:ptahcrowd,代码行数:31,代码来源:user.py

示例6: test_manage_disable_modules_traverse

    def test_manage_disable_modules_traverse(self):
        from ptah.manage.manage import \
            module, PtahModule, PtahManageRoute, set_access_manager

        @module('test-module')
        class TestModule(PtahModule):
            """ module description """

            title = 'Test module'

        def accessManager(id, request):
            return True

        self.init_ptah()

        set_access_manager(accessManager)
        ptah.auth_service.set_userid('test-user')

        cfg = ptah.get_settings(ptah.CFG_ID_PTAH, self.registry)
        cfg['disable_modules'] = ('test-module',)

        request = DummyRequest()
        route = PtahManageRoute(request)

        self.assertRaises(KeyError, route.__getitem__, 'test-module')
开发者ID:runyaga,项目名称:ptah,代码行数:25,代码来源:test_manage.py

示例7: test_validation_auth_checker_validation

    def test_validation_auth_checker_validation(self):
        from ptahcrowd.validation import validationAndSuspendedChecker

        principal = Principal('1', 'user', '[email protected]')

        cfg = ptah.get_settings(ptahcrowd.CFG_ID_CROWD)

        # validation disabled
        info = AuthInfo(principal, True)
        cfg['validation'] = False
        self.assertTrue(validationAndSuspendedChecker(info))

        info = AuthInfo(principal, True)
        cfg['allow-unvalidated'] = False
        self.assertTrue(validationAndSuspendedChecker(info))

        # validation enabled
        info = AuthInfo(principal, True)
        cfg['validation'] = True
        cfg['allow-unvalidated'] = False
        self.assertFalse(validationAndSuspendedChecker(info))
        self.assertEqual(info.message, 'Account is not validated.')

        info = AuthInfo(principal, True)
        cfg['allow-unvalidated'] = True
        self.assertTrue(validationAndSuspendedChecker(info))

        # validated
        principal.validated = True

        info = AuthInfo(principal, True)
        cfg['validation'] = True
        self.assertTrue(validationAndSuspendedChecker(info))
开发者ID:ptahproject,项目名称:ptahcrowd,代码行数:33,代码来源:test_validation.py

示例8: register_handler

    def register_handler(self):
        data, errors = self.extract()
        if errors:
            self.add_error_message(errors)
            return

        user = self.create(data)
        self.request.registry.notify(PrincipalRegisteredEvent(user))
        self.cfg = ptah.get_settings(CFG_ID_CROWD, self.request.registry)
        # validation
        if self.cfg['validation']:
            initiate_email_validation(user, self.request)
            self.request.add_message('Validation email has been sent.')
            if not self.cfg['allow-unvalidated']:
                return HTTPFound(location=self.request.application_url)

        # authenticate
        info = ptah.auth_service.authenticate(
            {'login': user.username, 'password': user.password})
        if info.status:
            headers = security.remember(self.request, info.__uri__)
            return HTTPFound(
                location='%s/login-success.html'%self.request.application_url,
                headers = headers)
        else:
            self.request.add_message(info.message) # pragma: no cover
开发者ID:djedproject,项目名称:ptahcrowd,代码行数:26,代码来源:registration.py

示例9: test_settings_export

    def test_settings_export(self):
        field1 = ptah.form.TextField(
            'node1',
            default = 'test')

        field2 = ptah.form.TextField(
            'node2',
            default = 'test1')

        ptah.register_settings('group4', field1, field2)
        self.init_ptah(initsettings=True)

        settings = get_settings_ob()

        # changed settings
        self.assertEqual(settings.export(), {})

        # default settings
        data = settings.export(default=True)
        self.assertIn('group4.node1', data)
        self.assertIn('group4.node2', data)
        self.assertEqual(data['group4.node1'], '"test"')
        self.assertEqual(data['group4.node2'], '"test1"')

        # changed settings
        group = ptah.get_settings('group4', self.registry)

        group['node2'] = 'changed'
        data = dict(settings.export())
        self.assertEqual(data['group4.node2'], '"changed"')
开发者ID:rainerwahnsinn,项目名称:ptah,代码行数:30,代码来源:test_settings.py

示例10: create

    def create(self):
        data, errors = self.extract()

        if errors:
            self.add_error_message(errors)
            return

        # create user
        cfg = ptah.get_settings(ptahcrowd.CFG_ID_CROWD, self.request.registry)
        tp = cfg['type']
        if not tp.startswith('type:'):
            tp = 'type:{0}'.format(tp)

        tinfo = ptah.resolve(tp)

        user = tinfo.create(
            fullname=data['fullname'], username=data['username'], email=data['email'],
            validated=data['validated'], suspended=data['suspended'])
        user.password = ptah.pwd_tool.encode(data['password'])

        tinfo.add(user)

        # notify system
        self.request.registry.notify(ptah.events.PrincipalAddedEvent(user))

        self.request.add_message('User has been created.', 'success')
        return HTTPFound(location='.')
开发者ID:ptahproject,项目名称:ptahcrowd,代码行数:27,代码来源:user.py

示例11: test_manage_disable_modules

    def test_manage_disable_modules(self):
        from ptah.manage.manage import module, PtahModule, PtahManageRoute, ManageView, set_access_manager

        @module("test-module")
        class TestModule(PtahModule):
            """ module description """

            title = "Test module"

        def accessManager(id, request):
            return True

        self.init_ptah()

        set_access_manager(accessManager)
        ptah.auth_service.set_userid("test-user")

        cfg = ptah.get_settings(ptah.CFG_ID_PTAH, self.registry)
        cfg["disable_modules"] = ("test-module",)

        request = DummyRequest()
        route = PtahManageRoute(request)

        view = ManageView(route, request)
        view.update()

        for mod in view.modules:
            self.assertFalse(isinstance(mod, TestModule))
开发者ID:webmaven,项目名称:ptah,代码行数:28,代码来源:test_manage.py

示例12: render_amd_includes

def render_amd_includes(request, spec='', bundles=()):
    registry = request.registry
    cfg = ptah.get_settings(ptah.CFG_ID_PTAH, request.registry)

    ptah.include(request, 'curl')

    c_tmpls = []
    if spec and cfg['amd-spec-enabled']:
        specstorage = request.registry.get(ID_AMD_SPEC, {})
        specdata = specstorage.get(spec)
        if specdata is None:
            raise RuntimeError("Spec '%s' is not found."%spec)
    else:
        spec = '_'
        specdata = ()

    for name in (bundles if not isinstance(bundles, str) else (bundles,)):
        name = '%s.js'%name
        if name in specdata:
            c_tmpls.append(
                '<script src="%s"></script>'%
                request.route_url('ptah-amd-spec',specname=spec,name=name))

    return amd_incl%{'app_url': request.application_url,
                     'specname': spec,
                     'components': '\n'.join(c_tmpls)}
开发者ID:webmaven,项目名称:ptah,代码行数:26,代码来源:amd.py

示例13: rebalance

def rebalance():
    ploud_config.initializeConfig()
    APACHE = ptah.get_settings('apache')
    file = APACHE['lbfile']
    processes = APACHE['processes']

    conn = ploud_config.PLOUD_POOL.getconn()
    c1 = conn.cursor()

    c1.execute("SELECT vhost.host,sites.bwin,sites.bwout,sites.site_name FROM vhost, sites "
               "WHERE vhost.id = sites.id and sites.disabled = %s ORDER by sites.id",(False,))

    db = bsddb.hashopen(file, 'w')

    data = [(bwin+bwout, host, name) for host, bwin, bwout, name in c1.fetchall()]
    data.sort()

    i = 1
    for size, host, name in data:
        db[host] = str(i)
        db[name] = str(i)
        i = i + 1
        if i > processes:
            i = 1

    print 'Rebalancing is done.'

    db.close()

    c1.close()
    conn.close()
开发者ID:enfold,项目名称:ploud.utils,代码行数:31,代码来源:routing.py

示例14: initialized

def initialized(ev):
    global PLOUD_DSN, CLIENTS_DSN
    global PLOUD_POOL, CLIENTS_POOL
    def parse_dsn(s):
        params = {}
        s = s.split('//', 1)[-1]

        if '@' in s:
            head, tail = s.split('@', 1)
            user, passwd = head.split(':', 1)
            host, dbname = tail.split('/', 1)
        else:
            user = passwd = host = dbname = ''

        params['user'] = user
        params['password'] = passwd
        params['host'] = host
        params['database'] = dbname
        return params

    PLOUD = ptah.get_settings('ploud', ev.registry)
    PLOUD_DSN = parse_dsn(PLOUD['dsn'])
    CLIENTS_DSN = parse_dsn(PLOUD['clientsdsn'])

    # Init ploud connections pool
    PLOUD_POOL = psycopg2.pool.ThreadedConnectionPool(0, 8, **PLOUD_DSN)
    CLIENTS_POOL = psycopg2.pool.ThreadedConnectionPool(0, 10, **CLIENTS_DSN)
开发者ID:enfold,项目名称:ploud.utils,代码行数:27,代码来源:ploud_config.py

示例15: get_user_type

def get_user_type(registry=None):
    cfg = ptah.get_settings(CFG_ID_CROWD, registry)
    tp = cfg["type"]
    if not tp.startswith("type:"):
        tp = "type:{0}".format(tp)

    return ptah.resolve(tp)
开发者ID:rainerwahnsinn,项目名称:ptahcrowd,代码行数:7,代码来源:provider.py


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