本文整理匯總了Python中wiki20.model.DBSession.query方法的典型用法代碼示例。如果您正苦於以下問題:Python DBSession.query方法的具體用法?Python DBSession.query怎麽用?Python DBSession.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wiki20.model.DBSession
的用法示例。
在下文中一共展示了DBSession.query方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: default
# 需要導入模塊: from wiki20.model import DBSession [as 別名]
# 或者: from wiki20.model.DBSession import query [as 別名]
def default(self, pagename="FrontPage"):
try:
page = DBSession.query(Page).filter_by(pagename=pagename).one()
except InvalidRequestError:
raise tg.redirect("notfound", pagename = pagename)
page = DBSession.query(Page).filter_by(pagename=pagename).one()
content = publish_parts(page.data, writer_name="html")["html_body"]
root = tg.url('/')
content = wikiwords.sub(r'<a href="%s\1">\1</a>' % root, content)
return dict(content=content, wikipage=page)
示例2: by_email_address
# 需要導入模塊: from wiki20.model import DBSession [as 別名]
# 或者: from wiki20.model.DBSession import query [as 別名]
def by_email_address(cls, email):
"""Return the user object whose email address is ``email``."""
return DBSession.query(cls).filter_by(email_address=email).first()
示例3: by_user_name
# 需要導入模塊: from wiki20.model import DBSession [as 別名]
# 或者: from wiki20.model.DBSession import query [as 別名]
def by_user_name(cls, username):
"""Return the user object whose user name is ``username``."""
return DBSession.query(cls).filter_by(user_name=username).first()
示例4: pagelist
# 需要導入模塊: from wiki20.model import DBSession [as 別名]
# 或者: from wiki20.model.DBSession import query [as 別名]
def pagelist(self):
pages = [page.pagename for page in DBSession.query(Page)]
return dict(pages=pages)
示例5: save
# 需要導入模塊: from wiki20.model import DBSession [as 別名]
# 或者: from wiki20.model.DBSession import query [as 別名]
def save(self, pagename, data, submit):
page = DBSession.query(Page).filter_by(pagename=pagename).one()
page.data = data
redirect("/" + pagename)
示例6: edit
# 需要導入模塊: from wiki20.model import DBSession [as 別名]
# 或者: from wiki20.model.DBSession import query [as 別名]
def edit(self, pagename):
page = DBSession.query(Page).filter_by(pagename=pagename).one()
return dict(wikipage=page)
示例7: index
# 需要導入模塊: from wiki20.model import DBSession [as 別名]
# 或者: from wiki20.model.DBSession import query [as 別名]
def index(self, pagename="FrontPage"):
"""Handle the front-page."""
page = DBSession.query(Page).filter_by(pagename=pagename).one()
return dict(wikipage=page)
示例8: index
# 需要導入模塊: from wiki20.model import DBSession [as 別名]
# 或者: from wiki20.model.DBSession import query [as 別名]
def index(self, pagename="FrontPage"):
page = DBSession.query(Page).filter_by(pagename=pagename).one()
return dict(wikipage=page)
示例9: _default
# 需要導入模塊: from wiki20.model import DBSession [as 別名]
# 或者: from wiki20.model.DBSession import query [as 別名]
def _default(self, pagename="FrontPage"):
page = DBSession.query(Page).filter_by(pagename=pagename).one()
content = publish_parts(page.data, writer_name="html")["html_body"]
root = url('/')
content = wikiwords.sub(r'<a href="%s\1">\1</a>' % root, content)
return dict(content=content, wikipage=page)
示例10: test_query_obj
# 需要導入模塊: from wiki20.model import DBSession [as 別名]
# 或者: from wiki20.model.DBSession import query [as 別名]
def test_query_obj(self):
"""Model objects can be queried"""
obj = DBSession.query(self.klass).one()
for key, value in self.attrs.iteritems():
assert_equals(getattr(obj, key), value)
示例11: save
# 需要導入模塊: from wiki20.model import DBSession [as 別名]
# 或者: from wiki20.model.DBSession import query [as 別名]
def save(self, pagename, data, submit):
page = DBSession.query(Page).filter_by(pagename=pagename).one()
page.data = data
DBSession.commit() # Tells database to commit changes permanently
redirect("/" + pagename)