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

Python odm.ThreadLocalORMSession类代码示例

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

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



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

示例1: test_disable_user

    def test_disable_user(self):
        # user was not pending
        assert_equal(M.User.by_username('test-user-3').disabled, False)
        assert_equal(M.User.by_username('test-user-3').pending, False)
        r = self.app.get('/nf/admin/user/test-user-3')
        form = r.forms[0]
        assert_equal(form['username'].value, 'test-user-3')
        assert_equal(form['status'].value, 'enable')
        form['status'].value = 'disable'
        with td.audits('Account disabled', user=True):
            r = form.submit()
            assert_equal(M.AuditLog.query.find().count(), 1)
        assert_in(u'User disabled', self.webflash(r))
        assert_equal(M.User.by_username('test-user-3').disabled, True)
        assert_equal(M.User.by_username('test-user-3').pending, False)

        # user was pending
        user = M.User.by_username('test-user-3')
        user.disabled = False
        user.pending = True
        ThreadLocalORMSession.flush_all()
        assert_equal(M.User.by_username('test-user-3').disabled, False)
        assert_equal(M.User.by_username('test-user-3').pending, True)
        r = self.app.get('/nf/admin/user/test-user-3')
        form = r.forms[0]
        assert_equal(form['username'].value, 'test-user-3')
        assert_equal(form['status'].value, 'pending')
        form['status'].value = 'disable'
        with td.audits('Account disabled', user=True):
            r = form.submit()
            assert_equal(M.AuditLog.query.find().count(), 1)
        assert_in(u'User disabled', self.webflash(r))
        assert_equal(M.User.by_username('test-user-3').disabled, True)
        assert_equal(M.User.by_username('test-user-3').pending, True)
开发者ID:abhinavthomas,项目名称:allura,代码行数:34,代码来源:test_site_admin.py


示例2: execute

 def execute(cls, options):
     duplicates = cls._find_duplicates()
     log.info('Found %s duplicate categories: %s', len(duplicates), duplicates.keys())
     for name, dups in duplicates.iteritems():
         projects_with_category = {}
         for dup in dups:
             projects = cls._projects_with_category(dup._id)
             projects_with_category[dup._id] = projects
         log.info('Following projects are using category %s:', name)
         for _id, ps in projects_with_category.iteritems():
             log.info('  with id %s: %s', _id, [p.shortname for p in ps])
         priority = [(i, len(ps)) for i, ps in projects_with_category.items()]
         priority = sorted(priority, key=itemgetter(1), reverse=True)
         priority = [p[0] for p in priority]
         live, kill = priority[0], priority[1:]
         log.info('%s will live %s will die', live, kill)
         if sum([len(projects_with_category[_id]) for _id in kill]) > 0:
             # Duplicates are used somewhere, need to reasign for all projects that use them
             projects = []
             ids_to_kill = set(kill)
             for p in [projects_with_category[_id] for _id in kill]:
                 projects.extend(p)
             for p in projects:
                 for tt in cls.trove_types:
                     _ids = ids_to_kill.intersection(getattr(p, tt))
                     for _id in _ids:
                         log.info('Removing %s from %s.%s and adding %s instead', _id, p.shortname, tt, live)
                         if not options.dry_run:
                             getattr(p, tt).remove(_id)
                             getattr(p, tt).append(live)
         log.info('Removing categories %s', kill)
         if not options.dry_run:
             M.TroveCategory.query.remove({'_id': {'$in': kill}})
         ThreadLocalORMSession.flush_all()
开发者ID:abhinavthomas,项目名称:allura,代码行数:34,代码来源:remove_duplicate_troves.py


示例3: main

def main():
    for chunk in utils.chunked_find(M.User):
        for user in chunk:
            print 'Processing {0}'.format(user.username)
            user.pending = False
            # Ming doesn't mark document for update, since pending is False
            # by default, even if field is missing from mongo
            state(user).status = state(user).dirty
            ThreadLocalORMSession.flush_all()
开发者ID:abhinavthomas,项目名称:allura,代码行数:9,代码来源:031-set-user-pending-to-false.py


示例4: main

def main():
    for chunk in utils.chunked_find(M.MergeRequest):
        for mr in chunk:
            try:
                print 'Processing {0}'.format(mr.url())
                mr.subscribe(user=mr.creator)
                ThreadLocalORMSession.flush_all()
            except:
                log.exception('Error on %s', mr)
开发者ID:apache,项目名称:allura,代码行数:9,代码来源:032-subscribe-merge-request-submitters.py


示例5: test_is_spam

 def test_is_spam(self, spam_checker):
     spam_checker.check.return_value = True
     c.user = M.User.query.get(username="test-user")
     role = M.ProjectRole(project_id=c.project._id, name='TestRole')
     M.ProjectRole.by_user(c.user, upsert=True).roles.append(role._id)
     ThreadLocalORMSession.flush_all()
     t = M.Thread()
     p = M.Post()
     assert_in('TestRole', [r.name for r in c.project.named_roles])
     assert_false(t.is_spam(p))
开发者ID:dastanforever,项目名称:allura,代码行数:10,代码来源:test_forum.py


示例6: test_new_projects_deleted_projects

 def test_new_projects_deleted_projects(self):
     '''Deleted projects should not be visible here'''
     r = self.app.get('/nf/admin/new_projects', extra_environ=dict(
         username='root'))
     count = len(r.html.find('table').findAll('tr'))
     p = M.Project.query.get(shortname='test')
     p.deleted = True
     ThreadLocalORMSession.flush_all()
     r = self.app.get('/nf/admin/new_projects', extra_environ=dict(
         username='root'))
     assert_equal(len(r.html.find('table').findAll('tr')), count - 1)
开发者ID:abhinavthomas,项目名称:allura,代码行数:11,代码来源:test_site_admin.py


示例7: test_create_limit

 def test_create_limit(self, import_tool, extractor):
     extractor.return_value.get_repo_type.return_value = "git"
     project = M.Project.query.get(shortname=test_project_with_repo)
     project.set_tool_data("GoogleRepoImporter", pending=1)
     ThreadLocalORMSession.flush_all()
     params = dict(gc_project_name="poop", mount_label="mylabel", mount_point="mymount")
     r = self.app.post(
         "/p/{}/admin/ext/import/google-code-repo/create".format(test_project_with_repo), params, status=302
     ).follow()
     self.assertIn("Please wait and try again", r)
     self.assertEqual(import_tool.post.call_count, 0)
开发者ID:heiths,项目名称:allura,代码行数:11,代码来源:test_code.py


示例8: test_create_limit

 def test_create_limit(self, import_tool):
     project = M.Project.query.get(shortname='test')
     project.set_tool_data('GoogleCodeTrackerImporter', pending=1)
     ThreadLocalORMSession.flush_all()
     params = dict(gc_project_name='test',
                   mount_label='mylabel',
                   mount_point='mymount',
                   )
     r = self.app.post('/p/test/admin/bugs/_importer/create', params,
                       status=302).follow()
     self.assertIn('Please wait and try again', r)
     self.assertEqual(import_tool.post.call_count, 0)
开发者ID:AsylumCorp,项目名称:incubator-allura,代码行数:12,代码来源:test_tracker.py


示例9: test_create_limit

 def test_create_limit(self, import_tool, sui):
     project = M.Project.query.get(shortname="test")
     project.set_tool_data("ForgeTrackerImporter", pending=1)
     ThreadLocalORMSession.flush_all()
     params = {
         "tickets_json": webtest.Upload("tickets.json", '{"key": "val"}'),
         "mount_label": "mylabel",
         "mount_point": "mymount",
     }
     r = self.app.post("/p/test/admin/bugs/_importer/create", params, status=302).follow()
     self.assertIn("Please wait and try again", r)
     self.assertEqual(import_tool.post.call_count, 0)
开发者ID:jekatgithub,项目名称:incubator-allura,代码行数:12,代码来源:test_tracker.py


示例10: test_record_result

    def test_record_result(self):
        config = {}
        artifact = WM.Page.query.get()
        user = M.User.query.get(username='test-user')

        SpamFilter(config).record_result(True, artifact, user)
        ThreadLocalORMSession.flush_all()

        results = SpamCheckResult.query.find().all()
        assert_equal(len(results), 1)
        assert_equal(results[0].result, True)
        assert_equal(results[0].user.username, 'test-user')
开发者ID:apache,项目名称:allura,代码行数:12,代码来源:test_spam_filter.py


示例11: test_create_limit

 def test_create_limit(self, import_tool):
     p = M.Project.query.get(shortname=test_project_with_wiki)
     p.set_tool_data('GitHubWikiImporter', pending=1)
     ThreadLocalORMSession.flush_all()
     params = dict(
         gh_user_name='spooky',
         gh_project_name='mulder',
         mount_point='gh-wiki',
         mount_label='GitHub Wiki')
     r = self.app.post(self.url + 'create', params, status=302).follow()
     self.assertIn('Please wait and try again', r)
     self.assertEqual(import_tool.post.call_count, 0)
开发者ID:jekatgithub,项目名称:incubator-allura,代码行数:12,代码来源:test_wiki.py


示例12: main

def main(start, cnt):
    n = M.Neighborhood.query.get(url_prefix='/p/')
    admin = M.User.by_username('admin1')
    #M.Project.query.remove({'shortname': re.compile('gen-proj-.*')})
    #ThreadLocalORMSession.flush_all()
    for i in range(start, cnt):
        name = 'gen-proj-{}'.format(i)
        project = n.register_project(name, admin)
        if (i-start) > 0 and (i-start) % 100 == 0:
            print 'Created {} projects'.format(i-start)
    print 'Flushing...'
    ThreadLocalORMSession.flush_all()
    print 'Done'
开发者ID:abhinavthomas,项目名称:allura,代码行数:13,代码来源:generate-projects.py


示例13: test_create_limit

 def test_create_limit(self, import_tool, requests):
     requests.head.return_value.status_code = 200
     p = M.Project.query.get(shortname=test_project_with_tracker)
     p.set_tool_data('GitHubTrackerImporter', pending=1)
     ThreadLocalORMSession.flush_all()
     params = dict(
         gh_user_name='spooky',
         gh_project_name='mulder',
         mount_point='issues',
         mount_label='Issues')
     r = self.app.post(self.url + 'create', params, status=302).follow()
     self.assertIn('Please wait and try again', r)
     self.assertEqual(import_tool.post.call_count, 0)
开发者ID:abhinavthomas,项目名称:allura,代码行数:13,代码来源:test_tracker.py


示例14: test_create_limit

 def test_create_limit(self, import_tool):
     project = M.Project.query.get(shortname=test_project_with_repo)
     project.set_tool_data('GitHubRepoImporter', pending=1)
     ThreadLocalORMSession.flush_all()
     params = dict(
             gh_user_name='spooky',
             gh_project_name='poop',
             mount_label='mylabel',
             mount_point='mymount',
             )
     r = self.app.post('/p/{}/admin/ext/import/github-repo/create'.format(test_project_with_repo),
             params,
             status=302).follow()
     self.assertIn('Please wait and try again', r)
     self.assertEqual(import_tool.post.call_count, 0)
开发者ID:jekatgithub,项目名称:incubator-allura,代码行数:15,代码来源:test_code.py


示例15: test_send_password_reset_link

    def test_send_password_reset_link(self, gen_message_id, sendmail):
        user = M.User.by_username('test-user')
        user.set_pref('email_address', '[email protected]')
        M.EmailAddress(email='[email protected]', confirmed=True, claimed_by_user_id=user._id)
        ThreadLocalORMSession.flush_all()
        with td.audits('Password recovery link sent to: [email protected]', user=True):
            r = self.app.post('/nf/admin/user/send_password_reset_link', params={'username': 'test-user'})
        hash = user.get_tool_data('AuthPasswordReset', 'hash')
        text = '''Your username is test-user

To reset your password on %s, please visit the following URL:

%s/auth/forgotten_password/%s''' % (config['site_name'], config['base_url'], hash)
        sendmail.post.assert_called_once_with(
            toaddr='[email protected]',
            fromaddr=config['forgemail.return_path'],
            reply_to=config['forgemail.return_path'],
            subject='Allura Password recovery',
            message_id=gen_message_id(),
            text=text)
开发者ID:abhinavthomas,项目名称:allura,代码行数:20,代码来源:test_site_admin.py


示例16: setUp

def setUp():
    setup_basic_test()
    ThreadLocalORMSession.close_all()
    setup_global_objects()
开发者ID:joequant,项目名称:allura,代码行数:4,代码来源:test_oauth.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python orm.session函数代码示例发布时间:2022-05-27
下一篇:
Python odm.ODMSession类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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