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


Python ThreadLocalORMSession.close_all方法代码示例

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


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

示例1: test_paged_diffs_with_detect_copies

# 需要导入模块: from ming.orm import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ThreadLocalORMSession import close_all [as 别名]
    def test_paged_diffs_with_detect_copies(self):
        # setup
        h.set_context('test', 'src-weird', neighborhood='Projects')
        repo_dir = pkg_resources.resource_filename(
            'forgegit', 'tests/data')
        repo = GM.Repository(
            name='weird-chars.git',
            fs_path=repo_dir,
            url_path='/src-weird/',
            tool='git',
            status='creating')
        repo.refresh()
        ThreadLocalORMSession.flush_all()
        ThreadLocalORMSession.close_all()

        diffs = repo.paged_diffs('346c52c1dddc729e2c2711f809336401f0ff925e')  # Test copy
        expected = {
            'added': [],
            'removed': [],
            'copied': [{'new': u'README.copy', 'old': u'README', 'ratio': 1.0}],
            'renamed': [],
            'changed': [u'README'],
            'total': 2,
        }
        assert_equals(diffs, expected)
        diffs = repo.paged_diffs('3cb2bbcd7997f89060a14fe8b1a363f01883087f')  # Test rename
        expected = {
            'added': [],
            'removed': [],
            'copied': [],
            'renamed': [{'new': u'README', 'old': u'README-copy.md', 'ratio': 1.0}],
            'changed': [],
            'total': 1,
        }
        assert_equals(diffs, expected)
开发者ID:heiths,项目名称:allura,代码行数:37,代码来源:test_repository.py

示例2: register_neighborhood_project

# 需要导入模块: from ming.orm import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ThreadLocalORMSession import close_all [as 别名]
 def register_neighborhood_project(self, neighborhood, users, allow_register=False):
     from allura import model as M
     shortname = '--init--'
     name = 'Home Project for %s' % neighborhood.name
     p = M.Project(neighborhood_id=neighborhood._id,
                   shortname=shortname,
                   name=name,
                   short_description='',
                   description=(
                       'You can edit this description in the admin page'),
                   homepage_title = '# ' + name,
                   last_updated = datetime.utcnow(),
                   is_nbhd_project=True,
                   is_root=True)
     try:
         p.configure_project(
             users=users,
             is_user_project=False,
             apps=[
                 ('Wiki', 'wiki', 'Wiki'),
                 ('admin', 'admin', 'Admin')])
     except:
         ThreadLocalORMSession.close_all()
         log.exception('Error registering project %s' % p)
         raise
     if allow_register:
         role_auth = M.ProjectRole.authenticated(p)
         security.simple_grant(p.acl, role_auth._id, 'register')
         state(p).soil()
     return p
开发者ID:srcclrapache1,项目名称:incubator-allura,代码行数:32,代码来源:plugin.py

示例3: main

# 需要导入模块: from ming.orm import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ThreadLocalORMSession import close_all [as 别名]
def main(options):
    log.addHandler(logging.StreamHandler(sys.stdout))
    log.setLevel(getattr(logging, options.log_level.upper()))

    g.solr = mock.Mock()
    preamble = options.dry_run and "Would delete" or "Deleting"
    options.preamble = preamble

    for nbhd in M.Neighborhood.query.find():
        q = {'neighborhood_id': nbhd._id}
        for projects in utils.chunked_find(M.Project, q):
            for p in projects:
                scrub_project(p, options)
            ThreadLocalORMSession.flush_all()
            ThreadLocalORMSession.close_all()

    log.info('%s %s EmailAddress documents' %
            (preamble, M.EmailAddress.query.find().count()))
    log.info('%s email addresses from %s User documents' %
            (preamble, M.User.query.find().count()))
    log.info('%s monitoring_email addresses from %s Forum documents' %
            (preamble, DM.Forum.query.find({"monitoring_email":
                                            {"$nin": [None, ""]}}).count()))

    if not options.dry_run:
        M.EmailAddress.query.remove()
        M.User.query.update({}, {"$set": {"email_addresses": []}}, multi=True)
        DM.Forum.query.update({"monitoring_email": {"$nin": [None, ""]}},
                              {"$set": {"monitoring_email": None}}, multi=True)
    return 0
开发者ID:AsylumCorp,项目名称:incubator-allura,代码行数:32,代码来源:scrub-allura-data.py

示例4: test_direct_sub

# 需要导入模块: from ming.orm import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ThreadLocalORMSession import close_all [as 别名]
 def test_direct_sub(self):
     self._subscribe()
     self._post_notification(text='A')
     self._post_notification(text='B')
     ThreadLocalORMSession.flush_all()
     ThreadLocalORMSession.close_all()
     M.Mailbox.fire_ready()
开发者ID:jekatgithub,项目名称:incubator-allura,代码行数:9,代码来源:test_notification.py

示例5: fork

# 需要导入模块: from ming.orm import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ThreadLocalORMSession import close_all [as 别名]
 def fork(self, project_id=None, mount_point=None, mount_label=None):
     # this shows the form and handles the submission
     security.require_authenticated()
     if not c.app.forkable: raise exc.HTTPNotFound
     from_repo = c.app.repo
     ThreadLocalORMSession.flush_all()
     ThreadLocalORMSession.close_all()
     from_project = c.project
     to_project = M.Project.query.get(_id=ObjectId(project_id))
     mount_label = mount_label or '%s - %s' % (c.project.name, c.app.config.options.mount_label)
     mount_point = (mount_point or from_project.shortname)
     if request.method != 'POST' or not mount_point:
         return dict(from_repo=from_repo,
                     user_project=c.user.private_project(),
                     mount_point=mount_point,
                     mount_label=mount_label)
     else:
         with h.push_config(c, project=to_project):
             if not to_project.database_configured:
                 to_project.configure_project(is_user_project=True)
             security.require(security.has_access(to_project, 'admin'))
             try:
                 to_project.install_app(
                     ep_name=from_repo.tool_name,
                     mount_point=mount_point,
                     mount_label=mount_label,
                     cloned_from_project_id=from_project._id,
                     cloned_from_repo_id=from_repo._id)
                 redirect(to_project.url()+mount_point+'/')
             except exc.HTTPRedirection:
                 raise
             except Exception, ex:
                 flash(str(ex), 'error')
                 redirect(request.referer)
开发者ID:johnsca,项目名称:incubator-allura,代码行数:36,代码来源:repository.py

示例6: get_mr_page

# 需要导入模块: from ming.orm import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ThreadLocalORMSession import close_all [as 别名]
 def get_mr_page(r):
     r = r.follow()  # get merge request page; creates bg task for determining commits
     task = M.MonQTask.query.get(task_name='allura.tasks.repo_tasks.determine_mr_commits', state='ready')
     task()
     ThreadLocalORMSession.close_all()  # close ming connections so that new data gets loaded later
     r = self.app.get(r.request.url)  # refresh, data should be there now
     return r
开发者ID:brondsem,项目名称:allura,代码行数:9,代码来源:test_controllers.py

示例7: setup_with_tools

# 需要导入模块: from ming.orm import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ThreadLocalORMSession import close_all [as 别名]
 def setup_with_tools(self):
     setup_global_objects()
     _clear_subscriptions()
     _clear_notifications()
     ThreadLocalORMSession.flush_all()
     ThreadLocalORMSession.close_all()
     M.notification.MAILBOX_QUIESCENT=None # disable message combining
开发者ID:jekatgithub,项目名称:incubator-allura,代码行数:9,代码来源:test_notification.py

示例8: main

# 需要导入模块: from ming.orm import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ThreadLocalORMSession import close_all [as 别名]
def main():
    for chunk in utils.chunked_find(M.Project):
        for p in chunk:
            p.install_app('activity')

        ThreadLocalORMSession.flush_all()
        ThreadLocalORMSession.close_all()
开发者ID:Bitergia,项目名称:allura,代码行数:9,代码来源:026-install-activity-tool.py

示例9: test_basic_task

# 需要导入模块: from ming.orm import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ThreadLocalORMSession import close_all [as 别名]
def test_basic_task():
    task = M.MonQTask.post(pprint.pformat, ([5,6],))
    ThreadLocalORMSession.flush_all()
    ThreadLocalORMSession.close_all()
    task = M.MonQTask.get()
    assert task
    task()
    assert task.result == 'I[5, 6]', task.result
开发者ID:Bitergia,项目名称:allura,代码行数:10,代码来源:test_monq.py

示例10: setUp

# 需要导入模块: from ming.orm import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ThreadLocalORMSession import close_all [as 别名]
def setUp():
    controller = TestController()
    controller.setUp()
    controller.app.get("/wiki/Home/")
    setup_global_objects()
    ThreadLocalORMSession.close_all()
    h.set_context("test", "wiki", neighborhood="Projects")
    ThreadLocalORMSession.flush_all()
    ThreadLocalORMSession.close_all()
开发者ID:johnsca,项目名称:incubator-allura,代码行数:11,代码来源:test_discussion.py

示例11: test_redo_trees

# 需要导入模块: from ming.orm import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ThreadLocalORMSession import close_all [as 别名]
 def test_redo_trees(self):
     old_tree = self.rev.tree
     del self.rev.tree
     M.repo.Tree.query.remove()
     ThreadLocalORMSession.close_all()
     new_tree =  self.rev.tree
     self.assertEqual(old_tree.tree_ids, new_tree.tree_ids)
     self.assertEqual(old_tree.blob_ids, new_tree.blob_ids)
     self.assertEqual(old_tree._id, new_tree._id)
开发者ID:pombredanne,项目名称:SourceForge-Allura,代码行数:11,代码来源:test_repository.py

示例12: test_commit

# 需要导入模块: from ming.orm import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ThreadLocalORMSession import close_all [as 别名]
    def test_commit(self):
        assert self.rev.primary() is self.rev
        assert self.rev.index_id().startswith('allura/model/repo/Commit#')
        self.rev.author_url
        self.rev.committer_url
        assert self.rev.tree._id == self.rev.tree_id
        assert self.rev.summary == self.rev.message.splitlines()[0]
        assert self.rev.shorthand_id() == '[1e146e]'
        assert self.rev.symbolic_ids == (
            ['master'], ['foo']), self.rev.symbolic_ids
        assert self.rev.url() == (
            '/p/test/src-git/ci/'
            '1e146e67985dcd71c74de79613719bef7bddca4a/')
        all_cis = list(self.repo.log(self.rev._id, id_only=True))
        assert len(all_cis) == 4
        c.lcid_cache = {}
        self.rev.tree.ls()
        # print self.rev.tree.readme()
        assert_equal(self.rev.tree.readme(), (
            'README', 'This is readme\nAnother Line\n'))
        assert self.rev.tree.path() == '/'
        assert self.rev.tree.url() == (
            '/p/test/src-git/ci/'
            '1e146e67985dcd71c74de79613719bef7bddca4a/'
            'tree/')
        self.rev.tree.by_name['README']
        assert self.rev.tree.is_blob('README') == True
        ThreadLocalORMSession.close_all()
        c.app = None
        converted = g.markdown.convert('[1e146e]')
        assert '1e146e' in converted, converted
        h.set_context('test', 'wiki', neighborhood='Projects')
        pg = WM.Page(
            title='Test Page', text='This is a commit reference: [1e146e]')
        ThreadLocalORMSession.flush_all()
        M.MonQTask.run_ready()
        for ci in pg.related_artifacts():
            assert ci.shorthand_id() == '[1e146e]', ci.shorthand_id()
            assert ci.url() == (
                '/p/test/src-git/ci/'
                '1e146e67985dcd71c74de79613719bef7bddca4a/')

        assert_equal(self.rev.authored_user, None)
        assert_equal(self.rev.committed_user, None)
        user = M.User.upsert('rick')
        email = user.claim_address('[email protected]')
        email.confirmed = True
        session(email).flush(email)
        rev = self.repo.commit(self.rev._id)  # to update cached values of LazyProperty
        assert_equal(rev.authored_user, user)
        assert_equal(rev.committed_user, user)
        assert_equal(
            sorted(rev.webhook_info.keys()),
            sorted(['id', 'url', 'timestamp', 'message', 'author',
                    'committer', 'added', 'removed', 'renamed', 'modified', 'copied']))
开发者ID:heiths,项目名称:allura,代码行数:57,代码来源:test_repository.py

示例13: setup_with_tools

# 需要导入模块: from ming.orm import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ThreadLocalORMSession import close_all [as 别名]
 def setup_with_tools(self):
     setup_global_objects()
     h.set_context('test', 'src-git', neighborhood='Projects')
     repo_dir = pkg_resources.resource_filename(
         'forgegit', 'tests/data')
     c.app.repo.fs_path = repo_dir
     c.app.repo.name = 'testgit.git'
     self.repo = c.app.repo
     self.repo.refresh()
     ThreadLocalORMSession.flush_all()
     ThreadLocalORMSession.close_all()
开发者ID:heiths,项目名称:allura,代码行数:13,代码来源:test_repository.py

示例14: _make_app

# 需要导入模块: from ming.orm import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ThreadLocalORMSession import close_all [as 别名]
 def _make_app(self, mount_point, name):
     h.set_context("test", mount_point, neighborhood="Projects")
     repo_dir = pkg_resources.resource_filename("forgesvn", "tests/data/")
     c.app.repo.fs_path = repo_dir
     c.app.repo.status = "ready"
     c.app.repo.name = name
     c.app.repo.refresh()
     if os.path.isdir(c.app.repo.tarball_path):
         shutil.rmtree(c.app.repo.tarball_path.encode("utf-8"))
     ThreadLocalORMSession.flush_all()
     ThreadLocalORMSession.close_all()
开发者ID:joequant,项目名称:allura,代码行数:13,代码来源:test_controllers.py

示例15: setUp

# 需要导入模块: from ming.orm import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ThreadLocalORMSession import close_all [as 别名]
 def setUp(self):
     super(TestMergeRequest, self).setUp()
     c.project.install_app('svn', 'test2')
     h.set_context('test', 'test2', neighborhood='Projects')
     self.repo2 = M.Repository(name='test2', tool='svn')
     self.repo2._impl = mock.Mock(spec=M.RepositoryImplementation())
     self.repo2._impl.log = lambda *a,**kw:(['foo'], [])
     self.repo2._impl._repo = self.repo2
     self.repo2.init_as_clone('/p/test/', 'test1', '/p/test/test1/')
     ThreadLocalORMSession.flush_all()
     ThreadLocalORMSession.close_all()
开发者ID:Bitergia,项目名称:allura,代码行数:13,代码来源:test_repo.py


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