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


Python models.DBSession类代码示例

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


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

示例1: _initTestingDB

def _initTestingDB():
    from tutorial.models import DBSession
    from tutorial.models import Base
    from sqlalchemy import create_engine
    engine = create_engine('sqlite://')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    Base.metadata.create_all(engine)
    return DBSession
开发者ID:DeanHodgkinson,项目名称:pyramid,代码行数:9,代码来源:tests.py

示例2: _initTestingDB

def _initTestingDB():
    from sqlalchemy import create_engine
    from tutorial.models import DBSession, Page, Base

    engine = create_engine("sqlite://")
    Base.metadata.create_all(engine)
    DBSession.configure(bind=engine)
    with transaction.manager:
        model = Page("FrontPage", "This is the front page")
        DBSession.add(model)
    return DBSession
开发者ID:GabLeRoux,项目名称:pyramid_tutorials,代码行数:11,代码来源:tests.py

示例3: add_page

def add_page(request):
    name = request.matchdict['pagename']
    if 'form.submitted' in request.params:
        session = DBSession()
        body = request.params['body']
        page = Page(name, body)
        session.add(page)
        return HTTPFound(location = route_url('view_page', request,
                                              pagename=name))
    save_url = route_url('add_page', request, pagename=name)
    page = Page('', '')
    return dict(page=page, save_url=save_url)
开发者ID:ppaez,项目名称:pyramid-sqla-wiki,代码行数:12,代码来源:views.py

示例4: edit_page

def edit_page(request):
    name = request.matchdict['pagename']
    session = DBSession()
    page = session.query(Page).filter_by(name=name).one()
    if 'form.submitted' in request.params:
        page.data = request.params['body']
        session.add(page)
        return HTTPFound(location = route_url('view_page', request,
                                              pagename=name))
    return dict(
        page=page,
        save_url = route_url('edit_page', request, pagename=name),
        )
开发者ID:ppaez,项目名称:pyramid-sqla-wiki,代码行数:13,代码来源:views.py

示例5: _initTestingDB

def _initTestingDB():
    from sqlalchemy import create_engine
    from tutorial.models import (
        DBSession,
        Page,
        Base
        )
    engine = create_engine('sqlite://')
    Base.metadata.create_all(engine)
    DBSession.configure(bind=engine)
    with transaction.manager:
        model = Page(name='FrontPage', data='This is the front page')
        DBSession.add(model)
    return DBSession
开发者ID:Falmarri,项目名称:pyramid,代码行数:14,代码来源:tests.py

示例6: test_it

 def test_it(self):
     from sqlalchemy import create_engine
     engine = create_engine('sqlite:///:memory:')
     self._callFUT(engine)
     from tutorial.models import DBSession, Page
     self.assertEqual(DBSession.query(Page).one().data,
         'This is the front page')
开发者ID:HorizonXP,项目名称:pyramid,代码行数:7,代码来源:tests.py

示例7: view_page

def view_page(request):
    matchdict = request.matchdict
    session = DBSession()
    page = session.query(Page).filter_by(name=matchdict['pagename']).one()

    def check(match):
        word = match.group(1)
        exists = session.query(Page).filter_by(name=word).all()
        if exists:
            view_url = route_url('view_page', request, pagename=word)
            return '<a href="%s">%s</a>' % (view_url, word)
        else:
            add_url = route_url('add_page', request, pagename=word)
            return '<a href="%s">%s</a>' % (add_url, word)

    content = publish_parts(page.data, writer_name='html')['html_body']
    content = wikiwords.sub(check, content)
    edit_url = route_url('edit_page', request,
                         pagename=matchdict['pagename'])
    return dict(page=page, content=content, edit_url=edit_url)
开发者ID:ppaez,项目名称:pyramid-sqla-wiki,代码行数:20,代码来源:views.py

示例8: view_page

def view_page(request):
    pagename = request.matchdict['pagename']
    session = DBSession()
    page = session.query(Page).filter_by(name=pagename).first()
    if page is None:
        return HTTPNotFound('No such page')

    def check(match):
        word = match.group(1)
        exists = session.query(Page).filter_by(name=word).all()
        if exists:
            view_url = route_url('view_page', request, pagename=word)
            return '<a href="%s">%s</a>' % (view_url, word)
        else:
            add_url = route_url('add_page', request, pagename=word)
            return '<a href="%s">%s</a>' % (add_url, word)

    content = publish_parts(page.data, writer_name='html')['html_body']
    content = wikiwords.sub(check, content)
    edit_url = route_url('edit_page', request, pagename=pagename)
    logged_in = authenticated_userid(request)
    return dict(page=page, content=content, edit_url=edit_url,
                logged_in=logged_in)
开发者ID:cjw296,项目名称:pyramid,代码行数:23,代码来源:views.py

示例9: test_it

 def test_it(self):
     self._callFUT({'sqlalchemy.url':'sqlite://'})
     from tutorial.models import DBSession, Page
     self.assertEqual(DBSession.query(Page).one().data,
         'This is the front page')
开发者ID:Hquant,项目名称:pyramid,代码行数:5,代码来源:tests.py

示例10: tearDown

 def tearDown(self):
     from tutorial.models import DBSession
     DBSession.remove()
开发者ID:Hquant,项目名称:pyramid,代码行数:3,代码来源:tests.py

示例11: setUp

 def setUp(self):
     from tutorial.models import DBSession
     DBSession.remove()
开发者ID:Hquant,项目名称:pyramid,代码行数:3,代码来源:tests.py

示例12: my_view

def my_view(request):
    dbsession = DBSession()
    root = dbsession.query(MyModel).filter(MyModel.name==u'root').first()
    return {'root':root, 'project':'tutorial'}
开发者ID:DeanHodgkinson,项目名称:pyramid,代码行数:4,代码来源:views.py

示例13: main

def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
    with transaction.manager:
        user=User(name='mohsen',lname='jahndideho',tel='0937239304',email='[email protected]',username='jahfdfufddf',password='10772',semat='test')
        nameh=Nameh(nnameh='اداری',mnameh='مرخصی',chnameh='درخواست مرخصی از ریاست',manameh='اابباتاا',recive='jh',ersal="jahandide",tarikher="jun",mohlat="feb",jahat="eghdam",peyvast="no",vaseiyat="T")
        p=Paygham(mpayam="hello",ersal="jahandide",img="tutorial\images\jahandide.jpg")
        pa=payam(mapyam="hello",mopyam="jkjkjk",ersal='jahandide',recive='jahandideh')
        g=groups(usr="jahandideh")
        e=etela(minfo="hihjgkdsfukfspffsdtffdkjlkl")
        erj=moerjah(mer="edgsaaffuuygff'isfdjdf")
        DBSession.add(pa)
        DBSession.add(g)
        DBSession.add(e)
        DBSession.add(erj)
        DBSession.add(p)
        DBSession.add(user)
        DBSession.add(nameh)
开发者ID:hjahandideh,项目名称:hjahandideh,代码行数:24,代码来源:initialize_db.py


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