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


Python DBSession.close方法代码示例

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


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

示例1: tearDown

# 需要导入模块: from c3smembership.models import DBSession [as 别名]
# 或者: from c3smembership.models.DBSession import close [as 别名]
 def tearDown(self):
     """
     clean up after a test case
     """
     DBSession.close()
     DBSession.remove()
     testing.tearDown()
开发者ID:ebora,项目名称:c3sMembership,代码行数:9,代码来源:test_utils.py

示例2: tearDown

# 需要导入模块: from c3smembership.models import DBSession [as 别名]
# 或者: from c3smembership.models.DBSession import close [as 别名]
 def tearDown(self):
     # maybe I need to check and remove globals here,
     # so the other tests are not compromised
     #del engine
     from c3smembership.models import DBSession
     DBSession.close()
     DBSession.remove()
开发者ID:AnneGilles,项目名称:c3sMembership,代码行数:9,代码来源:test_webtest.py

示例3: setUp

# 需要导入模块: from c3smembership.models import DBSession [as 别名]
# 或者: from c3smembership.models.DBSession import close [as 别名]
    def setUp(self):
        self.config = testing.setUp()
        self.config.include('pyramid_mailer.testing')
        try:
            DBSession.close()
            DBSession.remove()
            #print("removed old DBSession ===================================")
        except:
            #print("no DBSession to remove ==================================")
            pass
        #try:
        #    os.remove('test_webtest_functional.db')
        #    #print "deleted old test database"
        #except:
        #    pass
        #    #print "never mind"

        my_settings = {
            #'sqlalchemy.url': 'sqlite:///test_webtest_functional.db',
            'sqlalchemy.url': 'sqlite:///:memory:',
            'available_languages': 'da de en es fr',
            'c3smembership.mailaddr': '[email protected]'}
        engine = engine_from_config(my_settings)
        DBSession.configure(bind=engine)
        self.session = DBSession  # ()

        Base.metadata.create_all(engine)
        # dummy database entries for testing
        with transaction.manager:
            member1 = C3sMember(  # german
                firstname=u'SomeFirstnäme',
                lastname=u'SomeLastnäme',
                email=u'[email protected]',
                address1=u"addr one",
                address2=u"addr two",
                postcode=u"12345",
                city=u"Footown Mäh",
                country=u"Foocountry",
                locale=u"DE",
                date_of_birth=date.today(),
                email_is_confirmed=False,
                email_confirm_code=u'ABCDEFGFOO',
                password=u'arandompassword',
                date_of_submission=date.today(),
                membership_type=u'normal',
                member_of_colsoc=True,
                name_of_colsoc=u"GEMA",
                num_shares=u'23',
            )
            DBSession.add(member1)
            DBSession.flush()

        from c3smembership import main
        app = main({}, **my_settings)

        from webtest import TestApp
        self.testapp = TestApp(app)
开发者ID:ebora,项目名称:c3sMembership,代码行数:59,代码来源:test_webtest.py

示例4: setUp

# 需要导入模块: from c3smembership.models import DBSession [as 别名]
# 或者: from c3smembership.models.DBSession import close [as 别名]
    def setUp(self):
        """
        set up everything for a test case
        """
        self.config = testing.setUp()
        self.config.include('pyramid_mailer.testing')
        try:
            DBSession.close()
            DBSession.remove()
            #print("removing old DBSession ===================================")
        except:
            #print("no DBSession to remove ===================================")
            pass
        from sqlalchemy import create_engine
        #engine = create_engine('sqlite:///test_utils.db')
        engine = create_engine('sqlite:///:memory:')
        DBSession.configure(bind=engine)
        self.session = DBSession  # ()

        Base.metadata.create_all(engine)
        with transaction.manager:
            member1 = C3sMember(  # german
                firstname=u'SomeFirstnäme',
                lastname=u'SomeLastnäme',
                email=u'[email protected]',
                address1=u"addr one",
                address2=u"addr two",
                postcode=u"12345",
                city=u"Footown Mäh",
                country=u"Foocountry",
                locale=u"DE",
                date_of_birth=date.today(),
                email_is_confirmed=False,
                email_confirm_code=u'ABCDEFGBAR',
                password=u'arandompassword',
                date_of_submission=date.today(),
                membership_type=u'normal',
                member_of_colsoc=True,
                name_of_colsoc=u"GEMA",
                num_shares=u'23',
            )
            DBSession.add(member1)
            DBSession.flush()
开发者ID:ebora,项目名称:c3sMembership,代码行数:45,代码来源:test_utils.py

示例5: tearDown

# 需要导入模块: from c3smembership.models import DBSession [as 别名]
# 或者: from c3smembership.models.DBSession import close [as 别名]
 def tearDown(self):
     DBSession.close()
     DBSession.remove()
     os.remove('test_webtest_accountants.db')
     testing.tearDown()
开发者ID:krissik,项目名称:c3sMembership,代码行数:7,代码来源:test_webtest.py

示例6: tearDown

# 需要导入模块: from c3smembership.models import DBSession [as 别名]
# 或者: from c3smembership.models.DBSession import close [as 别名]
 def tearDown(self):
     DBSession.close()
     DBSession.remove()
     testing.tearDown()
开发者ID:ebora,项目名称:c3sMembership,代码行数:6,代码来源:test_new_member_webtest.py

示例7: setUp

# 需要导入模块: from c3smembership.models import DBSession [as 别名]
# 或者: from c3smembership.models.DBSession import close [as 别名]
    def setUp(self):
        self.config = testing.setUp()
        self.config.include('pyramid_mailer.testing')
        try:
            DBSession.close()
            DBSession.remove()
            #print "closed and removed DBSession"
        except:
            pass
            #print "no session to close"
        #try:
        #    os.remove('test_import.db')
        #    #print "deleted old test database"
        #except:
        #    pass
        #    #print "never mind"
       # self.session = DBSession()
        my_settings = {
            #'sqlalchemy.url': 'sqlite:///test_import.db',
            'sqlalchemy.url': 'sqlite:///:memory:',
            'available_languages': 'da de en es fr',
            'c3smembership.dashboard_number': '30'}
        engine = engine_from_config(my_settings)
        DBSession.configure(bind=engine)
        Base.metadata.create_all(engine)
        with transaction.manager:
            member1 = C3sMember(  # german
                firstname=u'SomeFirstnäme',
                lastname=u'SomeLastnäme',
                email=u'[email protected]',
                address1=u"addr one",
                address2=u"addr two",
                postcode=u"12345",
                city=u"Footown Mäh",
                country=u"Foocountry",
                locale=u"DE",
                date_of_birth=date.today(),
                email_is_confirmed=False,
                email_confirm_code=u'ABCDEFGFOO',
                password=u'arandompassword',
                date_of_submission=date.today(),
                membership_type=u'normal',
                member_of_colsoc=True,
                name_of_colsoc=u"GEMA",
                num_shares=u'23',
            )
            DBSession.add(member1)
            DBSession.flush()
            self.m1_last_pw_change = member1.last_password_change
        with transaction.manager:
                # a group for accountants/staff
            accountants_group = Group(name=u"staff")
            try:
                DBSession.add(accountants_group)
                DBSession.flush()
                #print("adding group staff")
            except:
                #print("could not add group staff.")
                pass
            # staff personnel
            staffer1 = C3sStaff(
                login=u"rut",
                password=u"berries",
                email=u"[email protected]",
            )
            staffer1.groups = [accountants_group]
            try:
                DBSession.add(accountants_group)
                DBSession.add(staffer1)
                DBSession.flush()
            except:
                #print("it borked! (rut)")
                pass

        from c3smembership import main
        app = main({}, **my_settings)
        from webtest import TestApp
        self.testapp = TestApp(app)
开发者ID:ebora,项目名称:c3sMembership,代码行数:80,代码来源:test_import_export.py


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