本文整理汇总了Python中ming.orm.ormsession.ThreadLocalORMSession.close_all方法的典型用法代码示例。如果您正苦于以下问题:Python ThreadLocalORMSession.close_all方法的具体用法?Python ThreadLocalORMSession.close_all怎么用?Python ThreadLocalORMSession.close_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ming.orm.ormsession.ThreadLocalORMSession
的用法示例。
在下文中一共展示了ThreadLocalORMSession.close_all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_related_links
# 需要导入模块: from ming.orm.ormsession import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ormsession.ThreadLocalORMSession import close_all [as 别名]
def test_related_links(self):
response = self.app.get('/wiki/TEST/').follow()
assert 'Edit TEST' in response
assert 'Related' not in response
self.app.post('/wiki/TEST/update', params={
'title': 'TEST',
'text': 'sometext',
'labels': '',
'viewable_by-0.id': 'all'})
self.app.post('/wiki/aaa/update', params={
'title': 'aaa',
'text': '',
'labels': '',
'viewable_by-0.id': 'all'})
self.app.post('/wiki/bbb/update', params={
'title': 'bbb',
'text': '',
'labels': '',
'viewable_by-0.id': 'all'})
h.set_context('test', 'wiki', neighborhood='Projects')
a = model.Page.query.find(dict(title='aaa')).first()
a.text = '\n[TEST]\n'
b = model.Page.query.find(dict(title='TEST')).first()
b.text = '\n[bbb]\n'
ThreadLocalORMSession.flush_all()
M.MonQTask.run_ready()
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
response = self.app.get('/wiki/TEST/')
assert 'Related' in response
assert 'aaa' in response
assert 'bbb' in response
示例2: test_ticket_move_with_different_custom_fields
# 需要导入模块: from ming.orm.ormsession import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ormsession.ThreadLocalORMSession import close_all [as 别名]
def test_ticket_move_with_different_custom_fields(self):
app1 = c.project.app_instance('bugs')
app2 = c.project.app_instance('bugs2')
app1.globals.custom_fields.extend([
{'name': '_test', 'type': 'string', 'label': 'Test field'},
{'name': '_test2', 'type': 'string', 'label': 'Test field 2'}])
app2.globals.custom_fields.append(
{'name': '_test', 'type': 'string', 'label': 'Test field'})
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
with h.push_context(c.project._id, app_config_id=app1.config._id):
ticket = Ticket.new()
ticket.summary = 'test ticket'
ticket.description = 'test description'
ticket.custom_fields['_test'] = 'test val'
ticket.custom_fields['_test2'] = 'test val 2'
t = ticket.move(app2.config)
assert_equal(t.summary, 'test ticket')
assert_equal(t.description, 'test description')
assert_equal(t.custom_fields['_test'], 'test val')
post = Post.query.find(dict(thread_id=ticket.discussion_thread._id)).first()
assert post is not None, 'No comment about ticket moving'
message = 'Ticket moved from /p/test/bugs/1/'
message += '\n\nCan\'t be converted:\n'
message += '\n- **_test2**: test val 2'
assert_equal(post.text, message)
示例3: test_ticket_move_with_users_not_in_project
# 需要导入模块: from ming.orm.ormsession import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ormsession.ThreadLocalORMSession import close_all [as 别名]
def test_ticket_move_with_users_not_in_project(self):
app1 = c.project.app_instance('bugs')
app2 = c.project.app_instance('bugs2')
app1.globals.custom_fields.extend([
{'name': '_user_field', 'type': 'user', 'label': 'User field'},
{'name': '_user_field_2', 'type': 'user', 'label': 'User field 2'}])
app2.globals.custom_fields.extend([
{'name': '_user_field', 'type': 'user', 'label': 'User field'},
{'name': '_user_field_2', 'type': 'user', 'label': 'User field 2'}])
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
from allura.websetup import bootstrap
bootstrap.create_user('test-user-0')
with h.push_context(c.project._id, app_config_id=app1.config._id):
ticket = Ticket.new()
ticket.summary = 'test ticket'
ticket.description = 'test description'
ticket.custom_fields['_user_field'] = 'test-user' # in project
ticket.custom_fields['_user_field_2'] = 'test-user-0' # not in project
ticket.assigned_to_id = User.by_username('test-user-0')._id # not in project
t = ticket.move(app2.config)
assert_equal(t.assigned_to_id, None)
assert_equal(t.custom_fields['_user_field'], 'test-user')
assert_equal(t.custom_fields['_user_field_2'], '')
post = Post.query.find(dict(thread_id=ticket.discussion_thread._id)).first()
assert post is not None, 'No comment about ticket moving'
message = 'Ticket moved from /p/test/bugs/1/'
message += '\n\nCan\'t be converted:\n'
message += '\n- **_user_field_2**: test-user-0 (user not in project)'
message += '\n- **assigned_to**: test-user-0 (user not in project)'
assert_equal(post.text, message)
示例4: main
# 需要导入模块: from ming.orm.ormsession import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ormsession.ThreadLocalORMSession import close_all [as 别名]
def main():
M.TroveCategory(trove_cat_id=670,
trove_parent_id=14,
shortname="agpl",
fullname="Affero GNU Public License",
fullpath="License :: OSI-Approved Open Source :: Affero GNU Public License")
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
示例5: load
# 需要导入模块: from ming.orm.ormsession import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ormsession.ThreadLocalORMSession import close_all [as 别名]
def load(self):
artifact_orm_session._get().skip_mod_date = True
self.load_pages()
self.project.notifications_disabled = False
artifact_orm_session._get().skip_mod_date = False
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
allura_base.log.info('Loading wiki done')
示例6: setUp
# 需要导入模块: from ming.orm.ormsession import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ormsession.ThreadLocalORMSession import close_all [as 别名]
def setUp():
g._push_object(Globals())
c._push_object(mock.Mock())
request._push_object(Request.blank('/'))
ThreadLocalORMSession.close_all()
M.EmailAddress.query.remove({})
M.OpenIdNonce.query.remove({})
M.OpenIdAssociation.query.remove({})
示例7: main
# 需要导入模块: from ming.orm.ormsession import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ormsession.ThreadLocalORMSession import close_all [as 别名]
def main():
broken_posts = BM.BlogPost.query.find(dict(neighborhood_id=None)).all()
for post in broken_posts:
c.project = post.app.project
c.app = post.app
post.neighborhood_id = post.app.project.neighborhood_id
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
示例8: main
# 需要导入模块: from ming.orm.ormsession import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ormsession.ThreadLocalORMSession import close_all [as 别名]
def main():
M.TroveCategory(trove_cat_id=862,
trove_parent_id=14,
shortname="lppl",
fullname="LaTeX Project Public License",
fullpath="License :: OSI-Approved Open Source :: LaTeX Project Public License")
M.TroveCategory(trove_cat_id=655,
trove_parent_id=432,
shortname="win64",
fullname="64-bit MS Windows",
fullpath="Operating System :: Grouping and Descriptive Categories :: 64-bit MS Windows")
M.TroveCategory(trove_cat_id=657,
trove_parent_id=418,
shortname="vista",
fullname="Vista",
fullpath="Operating System :: Modern (Vendor-Supported) Desktop Operating Systems :: Vista")
M.TroveCategory(trove_cat_id=851,
trove_parent_id=418,
shortname="win7",
fullname="Windows 7",
fullpath="Operating System :: Modern (Vendor-Supported) Desktop Operating Systems :: Windows 7")
M.TroveCategory(trove_cat_id=728,
trove_parent_id=315,
shortname="android",
fullname="Android",
fullpath="Operating System :: Handheld/Embedded Operating Systems :: Android")
M.TroveCategory(trove_cat_id=780,
trove_parent_id=315,
shortname="ios",
fullname="Apple iPhone",
fullpath="Operating System :: Handheld/Embedded Operating Systems :: Apple iPhone")
M.TroveCategory(trove_cat_id=863,
trove_parent_id=534,
shortname="architects",
fullname="Architects",
fullpath="Intended Audience :: by End-User Class :: Architects")
M.TroveCategory(trove_cat_id=864,
trove_parent_id=534,
shortname="auditors",
fullname="Auditors",
fullpath="Intended Audience :: by End-User Class :: Auditors")
M.TroveCategory(trove_cat_id=865,
trove_parent_id=534,
shortname="testers",
fullname="Testers",
fullpath="Intended Audience :: by End-User Class :: Testers")
M.TroveCategory(trove_cat_id=866,
trove_parent_id=534,
shortname="secpros",
fullname="Security Professionals",
fullpath="Intended Audience :: by End-User Class :: Security Professionals")
M.TroveCategory(trove_cat_id=867,
trove_parent_id=535,
shortname="secindustry",
fullname="Security",
fullpath="Intended Audience :: by Industry or Sector :: Security")
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
示例9: main
# 需要导入模块: from ming.orm.ormsession import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ormsession.ThreadLocalORMSession import close_all [as 别名]
def main():
M.TroveCategory(trove_cat_id=905,
trove_parent_id=14,
shortname='mpl20',
fullname='Mozilla Public License 2.0 (MPL 2.0)',
fullpath='License :: OSI-Approved Open Source :: Mozilla Public License 2.0 (MPL 2.0)')
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
示例10: wrapped
# 需要导入模块: from ming.orm.ormsession import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ormsession.ThreadLocalORMSession import close_all [as 别名]
def wrapped(*args, **kw):
user = M.User.by_username(username)
c.user = user
n = M.Neighborhood.query.get(name='Users')
shortname = 'u/' + username
p = M.Project.query.get(shortname=shortname, neighborhood_id=n._id)
if not p:
n.register_project(shortname, user=user, user_project=True)
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
return func(*args, **kw)
示例11: test_touch
# 需要导入模块: from ming.orm.ormsession import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ormsession.ThreadLocalORMSession import close_all [as 别名]
def test_touch(self):
self.new_ticket(summary='test touch')
h.set_context('test', 'bugs', neighborhood='Projects')
ticket = tm.Ticket.query.get(ticket_num=1)
old_date = ticket.mod_date
ticket.summary = 'changing the summary'
time.sleep(1)
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
ticket = tm.Ticket.query.get(ticket_num=1)
new_date = ticket.mod_date
assert new_date > old_date
示例12: main
# 需要导入模块: from ming.orm.ormsession import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ormsession.ThreadLocalORMSession import close_all [as 别名]
def main():
update_trove_cat(16, dict(fullname="GNU Library or Lesser General Public License version 2.0 (LGPLv2)", fullpath="License :: OSI-Approved Open Source :: GNU Library or Lesser General Public License version 2.0 (LGPLv2)"))
update_trove_cat(15, dict(fullname="GNU General Public License version 2.0 (GPLv2)", fullpath="License :: OSI-Approved Open Source :: GNU General Public License version 2.0 (GPLv2)"))
update_trove_cat(670, dict(trove_cat_id=628, fullname="Affero GNU Public License"))
create_trove_cat((868,13,"ccal","Creative Commons Attribution License","License :: Creative Commons Attribution License"))
create_trove_cat((869,868,"ccaslv2","Creative Commons Attribution ShareAlike License V2.0","License :: Creative Commons Attribution License :: Creative Commons Attribution ShareAlike License V2.0"))
create_trove_cat((870,868,"ccaslv3","Creative Commons Attribution ShareAlike License V3.0","License :: Creative Commons Attribution License :: Creative Commons Attribution ShareAlike License V3.0"))
create_trove_cat((871,868,"ccanclv2","Creative Commons Attribution Non-Commercial License V2.0","License :: Creative Commons Attribution License :: Creative Commons Attribution Non-Commercial License V2.0"))
create_trove_cat((680,14,"lgplv3","GNU Library or Lesser General Public License version 3.0 (LGPLv3)","License :: OSI-Approved Open Source :: GNU Library or Lesser General Public License version 3.0 (LGPLv3)"))
create_trove_cat((679,14,"gplv3","GNU General Public License version 3.0 (GPLv3)","License :: OSI-Approved Open Source :: GNU General Public License version 3.0 (GPLv3)"))
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
示例13: wrapped
# 需要导入模块: from ming.orm.ormsession import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ormsession.ThreadLocalORMSession import close_all [as 别名]
def wrapped(*args, **kw):
c.user = M.User.by_username(username)
p = M.Project.query.get(shortname=project_shortname)
c.project = p
if mount_point and not p.app_instance(mount_point):
c.app = p.install_app(ep_name, mount_point, mount_label, ordinal, **override_options)
if post_install_hook:
post_install_hook(c.app)
while M.MonQTask.run_ready('setup'):
pass
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
elif mount_point:
c.app = p.app_instance(mount_point)
return func(*args, **kw)
示例14: test_add_remove_label
# 需要导入模块: from ming.orm.ormsession import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ormsession.ThreadLocalORMSession import close_all [as 别名]
def test_add_remove_label(self):
r = self.app.get('/admin/trove')
form = r.forms['label_edit_form']
form['labels'].value = 'foo,bar,baz'
with audits('updated labels'):
r = form.submit()
r = r.follow()
p_nbhd = M.Neighborhood.query.get(name='Projects')
p = M.Project.query.get(shortname='test', neighborhood_id=p_nbhd._id)
assert p.labels == ['foo', 'bar', 'baz']
assert form['labels'].value == 'foo,bar,baz'
ThreadLocalORMSession.close_all()
form['labels'].value = 'asdf'
with audits('updated labels'):
r = form.submit()
r = r.follow()
p = M.Project.query.get(shortname='test', neighborhood_id=p_nbhd._id)
assert_equals(p.labels, ['asdf'])
assert form['labels'].value == 'asdf'
示例15: wrapped
# 需要导入模块: from ming.orm.ormsession import ThreadLocalORMSession [as 别名]
# 或者: from ming.orm.ormsession.ThreadLocalORMSession import close_all [as 别名]
def wrapped(*args, **kw):
c.user = M.User.by_username(username)
p = M.Project.query.get(shortname=project_shortname)
c.project = p
if mount_point and not p.app_instance(mount_point):
c.app = p.install_app(ep_name, mount_point, mount_label, ordinal, **override_options)
if post_install_hook:
post_install_hook(c.app)
if asbool(tg.config.get('smtp.mock')):
smtp_mock = patch('allura.lib.mail_util.smtplib.SMTP')
else:
smtp_mock = NullContextManager()
with smtp_mock:
while M.MonQTask.run_ready('setup'):
pass
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
elif mount_point:
c.app = p.app_instance(mount_point)
return func(*args, **kw)