本文整理汇总了Python中tagger.model.DBSession.flush方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.flush方法的具体用法?Python DBSession.flush怎么用?Python DBSession.flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tagger.model.DBSession
的用法示例。
在下文中一共展示了DBSession.flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_article
# 需要导入模块: from tagger.model import DBSession [as 别名]
# 或者: from tagger.model.DBSession import flush [as 别名]
def test_article(self):
"""controllers.admin.Controller.article is working properly"""
languageid, tadm = self._fill_db()
cat = Category(u'test_category', u'xx')
DBSession.add(cat)
article = Article(u'A Test Article!', cat, u'xx', tadm, u'random text')
DBSession.add(article)
DBSession.flush()
categoryid = cat.id
articleid = article.id
transaction.commit()
environ = {'REMOTE_USER': 'test_admin'}
response = self.app.get('/admin/article/', extra_environ=environ,
status=200)
tr = response.html.table.find('tr', articleid)
# Date
eq_(str(tr('td')[1]), '<td>test_category</td>')
eq_(str(tr('td')[2]), '<td>%s</td>' % articleid)
eq_(str(tr('td')[3]), '<td>A Test Article!</td>')
eq_(str(tr('td')[4]), '<td></td>')
eq_(str(tr('td')[5]), '<td>%s</td>' % languageid)
# Status
actions = tr('td')[7]
eq_(str(actions('a')[0]['class']), 'icon edit')
eq_(str(actions('a')[1]['class']), 'icon delete overlay')
eq_(str(actions('a')[2]['class']), 'icon publish')
示例2: _fill_db
# 需要导入模块: from tagger.model import DBSession [as 别名]
# 或者: from tagger.model.DBSession import flush [as 别名]
def _fill_db(self):
language = Language(u'xx', u'test language')
DBSession.add(language)
DBSession.flush()
languageid = language.id
transaction.commit()
return languageid.encode()
示例3: test_banner_set
# 需要导入模块: from tagger.model import DBSession [as 别名]
# 或者: from tagger.model.DBSession import flush [as 别名]
def test_banner_set(self):
"""controllers.admin.Controller.banner_set is working properly"""
languageid, tadm = self._fill_db()
media = Media(u'image', u'test image', u'/test.png', tadm, u'xx',
u'random text')
DBSession.add(media)
link = Link(u'test link', u'http://example.com', tadm, u'xx',
u'random text')
DBSession.add(link)
DBSession.flush()
mediaid = media.id
linkid = link.id
transaction.commit()
environ = {'REMOTE_USER': 'test_admin'}
response = self.app.post('/admin/banner_set',
dict(mediaid=mediaid,
linkid=linkid,
),
extra_environ=environ, status=302)
#redirected = response.follow(extra_environ=environ, status=200)
bc = DBSession.query(BannerContent).first()
eq_(bc.media_id, mediaid)
eq_(bc.link_id, linkid)
示例4: _fill_db
# 需要导入模块: from tagger.model import DBSession [as 别名]
# 或者: from tagger.model.DBSession import flush [as 别名]
def _fill_db(self):
tadm = DBSession.query(User).filter_by(user_name=u'test_admin').one()
language = Language(u'xx', u'test language')
DBSession.add(language)
DBSession.flush()
languageid = language.id
return languageid, tadm
示例5: test_comment
# 需要导入模块: from tagger.model import DBSession [as 别名]
# 或者: from tagger.model.DBSession import flush [as 别名]
def test_comment(self):
"""controllers.admin.Controller.comment is working properly"""
languageid, tadm = self._fill_db()
comment = Comment(u'anonymous', u'[email protected]', u'test comment')
DBSession.add(comment)
DBSession.flush()
commentid = comment.id
transaction.commit()
environ = {'REMOTE_USER': 'test_admin'}
response = self.app.get('/admin/comment/', extra_environ=environ,
status=200)
tr = response.html.table('tr')[1]
# Date
eq_(str(tr('td')[1]), '<td>%s</td>' % commentid)
eq_(str(tr('td')[2]), '<td></td>')
eq_(str(tr('td')[3]), '<td>anonymous</td>')
eq_(str(tr('td')[4]), '<td>[email protected]</td>')
eq_(str(tr('td')[5]), '<td>test comment</td>')
# Status
actions = tr('td')[7]
eq_(str(actions('a')[0]['class']), 'icon edit overlay')
eq_(str(actions('a')[1]['class']), 'icon delete overlay')
eq_(str(actions('a')[2]['class']), 'icon approve')
eq_(str(actions('a')[3]['class']), 'icon spam')
示例6: do_get_dependencies
# 需要导入模块: from tagger.model import DBSession [as 别名]
# 或者: from tagger.model.DBSession import flush [as 别名]
def do_get_dependencies(self):
try:
self.language = content.Language(id=u'xx', name=u'test_lang')
DBSession.add(self.language)
DBSession.flush()
return dict(lang=self.language.id,
)
except:
DBSession.rollback()
raise
示例7: _fill_db
# 需要导入模块: from tagger.model import DBSession [as 别名]
# 或者: from tagger.model.DBSession import flush [as 别名]
def _fill_db(self):
language = Language(u'xx', u'test_langugage')
DBSession.add(language)
tag = Tag(u'test tag', u'xx')
DBSession.add(tag)
DBSession.flush()
languageid = language.id
tagid = tag.id
transaction.commit()
return languageid, tagid.encode()
示例8: _fill_db
# 需要导入模块: from tagger.model import DBSession [as 别名]
# 或者: from tagger.model.DBSession import flush [as 别名]
def _fill_db(self):
language = Language(u'xx', u'test_langugage')
DBSession.add(language)
cat = Category(u'test category', u'xx', u'a test category')
DBSession.add(cat)
DBSession.flush()
languageid = language.id
categoryid = cat.id
transaction.commit()
return languageid, categoryid.encode()
示例9: post
# 需要导入模块: from tagger.model import DBSession [as 别名]
# 或者: from tagger.model.DBSession import flush [as 别名]
def post(self, articleid, name, languageid, text=None):
"""create a new Page"""
user = tmpl_context.user
article = DBSession.query(Article).get(articleid.decode())
page = Page(name, languageid, user, text)
article.pages.append(page)
DBSession.flush()
flash('%s %s' % (_('Created Page:'), page.string_id), 'ok')
return dict(redirect_to=url('/article/%s/edit' % article.id))
示例10: _fill_db
# 需要导入模块: from tagger.model import DBSession [as 别名]
# 或者: from tagger.model.DBSession import flush [as 别名]
def _fill_db(self):
tadm = DBSession.query(User).filter_by(user_name=u'test_admin').one()
language = Language(u'xx', u'test_langugage')
DBSession.add(language)
cat = Category(u'test_category', u'xx')
DBSession.add(cat)
article = Article(u'A Test Article!', cat, u'xx', tadm, u'random text')
DBSession.add(article)
DBSession.flush()
categoryid = cat.id
articleid = article.id
languageid = language.id
transaction.commit()
return languageid, categoryid, articleid
示例11: _fill_db
# 需要导入模块: from tagger.model import DBSession [as 别名]
# 或者: from tagger.model.DBSession import flush [as 别名]
def _fill_db(self):
tadm = DBSession.query(User).filter_by(user_name=u'test_admin').one()
language = Language(u'xx', u'test_langugage')
DBSession.add(language)
tag = Tag(u'test_tag', u'xx')
DBSession.add(tag)
media = Media(u'image', u'test image', u'/test.png', tadm, u'xx',
u'random text')
media.tags.append(tag)
DBSession.add(media)
DBSession.flush()
languageid = language.id
mediaid = media.id
transaction.commit()
return languageid, mediaid.encode()
示例12: _fill_db
# 需要导入模块: from tagger.model import DBSession [as 别名]
# 或者: from tagger.model.DBSession import flush [as 别名]
def _fill_db(self):
tadm = DBSession.query(User).filter_by(user_name=u'test_admin').one()
language = Language(u'xx', u'test_langugage')
DBSession.add(language)
link = Link(u'test link', u'http://example.com', tadm, u'xx',
u'random text')
DBSession.add(link)
comment = Comment(u'anonymous', u'[email protected]', u'test comment')
DBSession.add(comment)
link.comments.append(comment)
DBSession.flush()
associableid = link.associable.id
commentid = comment.id
transaction.commit()
return associableid, commentid
示例13: _fill_db
# 需要导入模块: from tagger.model import DBSession [as 别名]
# 或者: from tagger.model.DBSession import flush [as 别名]
def _fill_db(self):
tadm = DBSession.query(User).filter_by(user_name=u'test_admin').one()
language = Language(u'xx', u'test_langugage')
DBSession.add(language)
tag = Tag(u'test_tag', u'xx')
DBSession.add(tag)
link = Link(u'test link', u'http://example.com', tadm, u'xx',
u'random text')
link.tags.append(tag)
DBSession.add(link)
DBSession.flush()
languageid = language.id
linkid = link.id
transaction.commit()
return languageid, linkid.encode()
示例14: test_tag
# 需要导入模块: from tagger.model import DBSession [as 别名]
# 或者: from tagger.model.DBSession import flush [as 别名]
def test_tag(self):
"""controllers.admin.Controller.tag is working properly"""
languageid, tadm = self._fill_db()
tag = Tag(u'test tag', u'xx')
DBSession.add(tag)
DBSession.flush()
tagid = tag.id
transaction.commit()
environ = {'REMOTE_USER': 'test_admin'}
response = self.app.get('/admin/tag/', extra_environ=environ,
status=200)
tr = response.html.table('tr')[1]
eq_(str(tr('td')[0]), '<td>%s</td>' % tagid)
eq_(str(tr('td')[1]), '<td>test tag</td>')
eq_(str(tr('td')[2]), '<td>%s</td>' % languageid)
actions = tr('td')[3]
eq_(str(actions('a')[0]['class']), 'icon edit overlay')
eq_(str(actions('a')[1]['class']), 'icon delete overlay')
示例15: test_category
# 需要导入模块: from tagger.model import DBSession [as 别名]
# 或者: from tagger.model.DBSession import flush [as 别名]
def test_category(self):
"""controllers.admin.Controller.category is working properly"""
languageid, tadm = self._fill_db()
category = Category(u'test category', u'xx', u'a test category')
DBSession.add(category)
DBSession.flush()
categoryid = category.id
transaction.commit()
environ = {'REMOTE_USER': 'test_admin'}
response = self.app.get('/admin/category/', extra_environ=environ,
status=200)
tr = response.html.table.find('tr', categoryid)
eq_(str(tr('td')[0]), '<td>%s</td>' % categoryid)
eq_(str(tr('td')[1]), '<td>test category</td>')
eq_(str(tr('td')[2]), '<td>a test category</td>')
eq_(str(tr('td')[3]), '<td>%s</td>' % languageid)
actions = tr('td')[4]
eq_(str(actions('a')[0]['class']), 'icon edit overlay')
eq_(str(actions('a')[1]['class']), 'icon delete overlay')