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


Python model.DBSession类代码示例

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


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

示例1: default

 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)
开发者ID:,项目名称:,代码行数:10,代码来源:

示例2: setUp

 def setUp(self):
     """Prepare model test fixture."""
     try:
         new_attrs = {}
         new_attrs.update(self.attrs)
         new_attrs.update(self.do_get_dependencies())
         self.obj = self.klass(**new_attrs)
         DBSession.add(self.obj)
         DBSession.flush()
         return self.obj
     except:
         DBSession.rollback()
         raise
开发者ID:TurboGears,项目名称:tg2tut,代码行数:13,代码来源:__init__.py

示例3: pagelist

 def pagelist(self):
     pages = [page.pagename for page in DBSession.query(Page)]
     return dict(pages=pages)
开发者ID:clsdaniel,项目名称:tg2docs,代码行数:3,代码来源:controllers_root_v8.py

示例4: notfound

 def notfound(self, pagename):
     page = Page(pagename=pagename, data="")
     DBSession.add(page)
     return dict(wikipage=page)
开发者ID:clsdaniel,项目名称:tg2docs,代码行数:4,代码来源:controllers_root_v8.py

示例5: save

 def save(self, pagename, data, submit):
     page = DBSession.query(Page).filter_by(pagename=pagename).one()
     page.data = data
     redirect("/" + pagename)
开发者ID:clsdaniel,项目名称:tg2docs,代码行数:4,代码来源:controllers_root_v8.py

示例6: edit

 def edit(self, pagename):
     page = DBSession.query(Page).filter_by(pagename=pagename).one()
     return dict(wikipage=page)
开发者ID:clsdaniel,项目名称:tg2docs,代码行数:3,代码来源:controllers_root_v8.py

示例7: create_engine

from wiki20.model import DBSession, Page, metadata
from sqlalchemy import create_engine

# Prepare the database connection
engine = create_engine("sqlite:///devdata.db", echo=True)
DBSession.configure(bind=engine)

# Create the tables
metadata.drop_all(engine)
metadata.create_all(engine)

# Create a page object and set some data
page = Page("FrontPage", "initial data")

# Save the page object to the in memory DBSession
DBSession.save(page)

# Use commit() to write all in-memory changes to the database.
DBSession.commit()

开发者ID:,项目名称:,代码行数:19,代码来源:

示例8: index

 def index(self, pagename="FrontPage"):
     """Handle the front-page."""
     page = DBSession.query(Page).filter_by(pagename=pagename).one()
     return dict(wikipage=page)
开发者ID:txdywy,项目名称:wiki20,代码行数:4,代码来源:root.py

示例9: save

 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)
开发者ID:,项目名称:,代码行数:5,代码来源:

示例10: _default

 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)
开发者ID:clsdaniel,项目名称:tg2docs,代码行数:6,代码来源:controllers_root_v5.py

示例11: test_query_obj

 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)
开发者ID:TurboGears,项目名称:tg2tut,代码行数:5,代码来源:__init__.py

示例12: tearDown

 def tearDown(self):
     """Finish model test fixture."""
     DBSession.rollback()
开发者ID:TurboGears,项目名称:tg2tut,代码行数:3,代码来源:__init__.py

示例13: notfound

 def notfound(self, pagename):
     page = Page(pagename=pagename, data="")
     DBSession.save(page)
     DBSession.commit()
     return dict(wikipage=page)
开发者ID:,项目名称:,代码行数:5,代码来源:

示例14: by_user_name

 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()
开发者ID:garrettmc,项目名称:TGWikiTutorial,代码行数:3,代码来源:auth.py

示例15: by_email_address

 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()
开发者ID:garrettmc,项目名称:TGWikiTutorial,代码行数:3,代码来源:auth.py


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