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


Python DBSession.flush方法代码示例

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


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

示例1: setup_method

# 需要导入模块: from c2cgeoportal_commons.models import DBSession [as 别名]
# 或者: from c2cgeoportal_commons.models.DBSession import flush [as 别名]
    def setup_method(self, _):
        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import Role, LayerWMS, RestrictionArea, Interface
        from c2cgeoportal_commons.models.static import User

        ogc_server_internal, _ = create_default_ogcserver()

        user1 = User(username="__test_user1", password="__test_user1")
        role1 = Role(name="__test_role1", description="__test_role1")
        user1.role_name = role1.name
        user1.email = "Tarenpion"

        main = Interface(name="main")

        layer1 = LayerWMS("testpoint_group_name", public=False)
        layer1.layer = "testpoint_group"
        layer1.ogc_server = ogc_server_internal
        layer1.interfaces = [main]

        layer2 = LayerWMS("testpoint_protected_2_name", public=False)
        layer2.layer = "testpoint_protected_2"
        layer2.ogc_server = ogc_server_internal
        layer2.interfaces = [main]

        area = "POLYGON((-100 30, -100 50, 100 50, 100 30, -100 30))"
        area = WKTElement(area, srid=21781)
        restricted_area1 = RestrictionArea("__test_ra1", "", [layer1, layer2], [role1], area)

        DBSession.add_all([user1, role1, layer1, layer2, restricted_area1])
        DBSession.flush()

        transaction.commit()
开发者ID:yjacolin,项目名称:c2cgeoportal,代码行数:34,代码来源:test_mapserverproxy_group.py

示例2: setup_method

# 需要导入模块: from c2cgeoportal_commons.models import DBSession [as 别名]
# 或者: from c2cgeoportal_commons.models.DBSession import flush [as 别名]
    def setup_method(self, _):
        self.maxDiff = None

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.static import User

        user = User(username="__test_user1", password="__test_user1")
        DBSession.add(user)
        DBSession.flush()

        self.old_remember = pyramid.security.remember
        self.user = None

        def remember(request, user=None):
            self.user = user

        pyramid.security.remember = remember
开发者ID:yjacolin,项目名称:c2cgeoportal,代码行数:19,代码来源:test_urllogin.py

示例3: setup_method

# 需要导入模块: from c2cgeoportal_commons.models import DBSession [as 别名]
# 或者: from c2cgeoportal_commons.models.DBSession import flush [as 别名]
    def setup_method(self, _):
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import Role, LayerWMS, RestrictionArea, \
            Functionality, Interface, OGCServer, OGCSERVER_TYPE_GEOSERVER, OGCSERVER_AUTH_GEOSERVER
        from c2cgeoportal_commons.models.static import User

        cleanup_db()

        ogc_server_internal, _ = create_default_ogcserver()
        ogcserver_geoserver = OGCServer(name="__test_ogc_server_geoserver")
        ogcserver_geoserver.url = mapserv_url
        ogcserver_geoserver.type = OGCSERVER_TYPE_GEOSERVER
        ogcserver_geoserver.auth = OGCSERVER_AUTH_GEOSERVER

        PointTest.__table__.create(bind=DBSession.bind, checkfirst=True)

        geom = WKTElement("POINT(599910 199955)", srid=21781)
        p1 = PointTest(geom=geom, name="foo", city="Lausanne", country="Swiss")
        geom = WKTElement("POINT(599910 200045)", srid=21781)
        p2 = PointTest(geom=geom, name="bar", city="Chambéry", country="France")
        geom = WKTElement("POINT(600090 200045)", srid=21781)
        p3 = PointTest(geom=geom, name="éàè", city="Paris", country="France")
        geom = WKTElement("POINT(600090 199955)", srid=21781)
        p4 = PointTest(geom=geom, name="123", city="Londre", country="UK")

        pt1 = Functionality(name="print_template", value="1 Wohlen A4 portrait")
        pt2 = Functionality(name="print_template", value="2 Wohlen A3 landscape")
        user1 = User(username="__test_user1", password="__test_user1")
        role1 = Role(name="__test_role1", description="__test_role1", functionalities=[pt1, pt2])
        user1.role_name = role1.name
        user1.email = "Tarenpion"

        user2 = User(username="__test_user2", password="__test_user2")
        role2 = Role(name="__test_role2", description="__test_role2", functionalities=[pt1, pt2])
        user2.role_name = role2.name
        user2.email = "Tarenpion"

        user3 = User(username="__test_user3", password="__test_user3")
        role3 = Role(name="__test_role3", description="__test_role3", functionalities=[pt1, pt2])
        user3.role_name = role3.name

        main = Interface(name="main")

        layer2 = LayerWMS("testpoint_protected", public=False)
        layer2.layer = "testpoint_protected"
        layer2.ogc_server = ogc_server_internal
        layer2.interfaces = [main]

        layer3 = LayerWMS("testpoint_protected_query_with_collect", public=False)
        layer3.layer = "testpoint_protected_query_with_collect"
        layer3.ogc_server = ogc_server_internal
        layer3.interfaces = [main]

        area = "POLYGON((599900 200030, 599900 200050, 600100 200050, 600100 200030, 599900 200030))"
        area = WKTElement(area, srid=21781)
        restricted_area1 = RestrictionArea("__test_ra1", "", [layer2, layer3], [role1], area)

        area = "POLYGON((599900 200000, 599900 200020, 600100 200020, 600100 200000, 599900 200000))"
        area = WKTElement(area, srid=21781)
        restricted_area2 = RestrictionArea("__test_ra2", "", [layer2, layer3], [role2, role3], area)

        area = "POLYGON((599905 200043, 599905 200047, 600095 200047, 600095 200043, 599905 200043))"
        area = WKTElement(area, srid=21781)
        restricted_area3 = RestrictionArea("__test_ra3", "", [layer3], [role3], area, readwrite=True)

        DBSession.add_all([
            p1, p2, p3, p4, user1, user2, user3, role1, role2, role3,
            restricted_area1, restricted_area2, restricted_area3, ogcserver_geoserver
        ])
        DBSession.flush()

        self.id_lausanne = p1.id
        self.id_paris = p3.id
        self.ogc_server_id = ogc_server_internal.id
        self.role1_id = role1.id
        self.role2_id = role2.id
        self.role3_id = role3.id

        transaction.commit()
开发者ID:yjacolin,项目名称:c2cgeoportal,代码行数:85,代码来源:test_mapserverproxy.py


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