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


Python models.DBSession类代码示例

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


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

示例1: setup_method

    def setup_method(self, _):
        import transaction
        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import Role, Functionality
        from c2cgeoportal_commons.models.static import User

        create_default_ogcserver()
        role1 = Role(name="__test_role1")
        user1 = User(
            username="__test_user1",
            password="__test_user1",
            role=role1
        )
        role2 = Role(name="__test_role2")
        user2 = User(
            username="__test_user2",
            password="__test_user2",
            role=role2
        )

        functionality1 = Functionality("__test_s", "db")
        functionality2 = Functionality("__test_a", "db1")
        functionality3 = Functionality("__test_a", "db2")
        role2.functionalities = [functionality1, functionality2, functionality3]

        DBSession.add_all([user1, user2, role1, role2])
        transaction.commit()
开发者ID:yjacolin,项目名称:c2cgeoportal,代码行数:27,代码来源:test_functionalities.py

示例2: setup_method

    def setup_method(self, _):
        import transaction
        from sqlalchemy import func
        from geoalchemy2 import WKTElement
        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import FullTextSearch, Role, Interface
        from c2cgeoportal_commons.models.static import User

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

        user2 = User(username="__test_user2", password="__test_user2")
        role2 = Role(name="__test_role2", description="__test_role2")
        user2.role_name = role2.name

        entry1 = FullTextSearch()
        entry1.label = "label1"
        entry1.layer_name = "layer1"
        entry1.ts = func.to_tsvector("french", "soleil travail")
        entry1.the_geom = WKTElement("POINT(-90 -45)", 21781)
        entry1.public = True

        entry2 = FullTextSearch()
        entry2.label = "label2"
        entry2.layer_name = "layer2"
        entry2.ts = func.to_tsvector("french", "pluie semaine")
        entry2.the_geom = WKTElement("POINT(-90 -45)", 21781)
        entry2.public = False

        entry3 = FullTextSearch()
        entry3.label = "label3"
        entry3.layer_name = "layer3"
        entry3.ts = func.to_tsvector("french", "vent neige")
        entry3.the_geom = WKTElement("POINT(-90 -45)", 21781)
        entry3.public = False
        entry3.role = role2

        entry4 = FullTextSearch()
        entry4.label = "label4"
        entry4.layer_name = "layer1"
        entry4.ts = func.to_tsvector("french", "soleil travail")
        entry4.the_geom = WKTElement("POINT(-90 -45)", 21781)
        entry4.public = True

        entry5 = FullTextSearch()
        entry5.label = "label5"
        entry5.ts = func.to_tsvector("french", "params")
        entry5.public = True
        entry5.params = {"floor": 5}
        entry5.actions = [{"action": "add_layer", "data": "layer1"}]

        entry6 = FullTextSearch()
        entry6.label = "label6"
        entry6.ts = func.to_tsvector("french", "params")
        entry6.interface = Interface("main")
        entry6.public = True

        DBSession.add_all([user1, user2, role1, role2, entry1, entry2, entry3, entry4, entry5, entry6])
        transaction.commit()
开发者ID:yjacolin,项目名称:c2cgeoportal,代码行数:60,代码来源:test_fulltextsearch.py

示例3: setup_method

    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 Theme, LayerGroup, Interface, LayerWMS

        main = Interface(name="desktop")

        ogc_server, _ = create_default_ogcserver()

        layer_wms = LayerWMS(name="__test_layer_wms", public=True)
        layer_wms.layer = "testpoint_unprotected"
        layer_wms.interfaces = [main]
        layer_wms.ogc_server = ogc_server

        layer_group = LayerGroup(name="__test_layer_group")
        layer_group.children = [layer_wms]

        theme = Theme(name="__test/theme")
        theme.interfaces = [main]
        theme.children = [
            layer_group
        ]

        DBSession.add(theme)
        transaction.commit()
开发者ID:yjacolin,项目名称:c2cgeoportal,代码行数:28,代码来源:test_themes_nameerror.py

示例4: setup_method

    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,代码行数:32,代码来源:test_mapserverproxy_group.py

示例5: teardown_method

    def teardown_method(self, _):
        testing.tearDown()

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.static import Shorturl
        import transaction
        DBSession.query(Shorturl).delete()
        transaction.commit()
开发者ID:yjacolin,项目名称:c2cgeoportal,代码行数:8,代码来源:test_shortener.py

示例6: get_private_layers

def get_private_layers(ogc_server_ids):
    q = DBSession.query(LayerWMS) \
        .filter(LayerWMS.public.is_(False)) \
        .join(LayerWMS.ogc_server) \
        .filter(OGCServer.id.in_(ogc_server_ids))
    results = q.all()
    DBSession.expunge_all()
    return {r.id: r for r in results}
开发者ID:yjacolin,项目名称:c2cgeoportal,代码行数:8,代码来源:filter_capabilities.py

示例7: get_ogcserver_byname

 def get_ogcserver_byname(self, name):
     try:
         result = DBSession.query(OGCServer).filter(OGCServer.name == name).one()
         DBSession.expunge(result)
         return result
     except NoResultFound:  # pragma nocover
         log.error("OGSServer '{}' does not exists (existing: {}).".format(
             name, ",".join([t[0] for t in DBSession.query(OGCServer.name).all()])))
         raise
开发者ID:yjacolin,项目名称:c2cgeoportal,代码行数:9,代码来源:ogcproxy.py

示例8: teardown_method

    def teardown_method(self, _):
        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.static import User

        DBSession.query(User).filter(User.username == "__test_user1").delete()
        transaction.commit()

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

示例9: teardown_method

    def teardown_method(self, _):
        import transaction
        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import Role
        from c2cgeoportal_commons.models.static import User

        transaction.commit()

        DBSession.query(User).filter_by(username="__test_user").delete()
        DBSession.query(Role).filter_by(name="__test_role").delete()
        transaction.commit()
开发者ID:yjacolin,项目名称:c2cgeoportal,代码行数:11,代码来源:test_request_property.py

示例10: setUp

    def setUp(self):  # noqa
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        self.clean()

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.static import User
        from c2cgeoportal_commons.models.main import \
            Theme, LayerGroup, Interface, LayerWMS, LayerWMTS, Role, RestrictionArea

        main = Interface(name=u"desktop")
        role = Role(name=u"__test_role")
        user = User(username=u"__test_user", password=u"__test_user", role=role)
        user.email = "[email protected]"
        ogc_server_internal, _ = create_default_ogcserver()

        layer_wms = LayerWMS(name=u"__test_layer_wms", public=True)
        layer_wms.layer = "__test_public_layer"
        layer_wms.interfaces = [main]
        layer_wms.ogc_server = ogc_server_internal

        layer_wms_private = LayerWMS(name=u"__test_layer_wms_private", public=True)
        layer_wms_private.layer = "__test_private_layer"
        layer_wms_private.public = False
        layer_wms_private.interfaces = [main]
        layer_wms_private.ogc_server = ogc_server_internal

        layer_wmts = LayerWMTS(name=u"__test_layer_wmts", public=True)
        layer_wmts.url = "http://example.com/1.0.0/WMTSCapabilities.xml"
        layer_wmts.layer = "map"
        layer_wmts.interfaces = [main]

        layer_wmts_private = LayerWMTS(name=u"__test_layer_wmts_private", public=True)
        layer_wmts_private.url = "http://example.com/1.0.0/WMTSCapabilities.xml"
        layer_wmts_private.layer = "map"
        layer_wmts_private.public = False
        layer_wmts_private.interfaces = [main]

        layer_group = LayerGroup(name=u"__test_layer_group")
        layer_group.children = [layer_wms, layer_wms_private, layer_wmts, layer_wmts_private]

        theme = Theme(name=u"__test_theme")
        theme.interfaces = [main]
        theme.children = [layer_group]

        restriction_area = RestrictionArea(
            name=u"__test_ra1", layers=[layer_wms_private, layer_wmts_private], roles=[role]
        )

        DBSession.add_all([theme, restriction_area, user])

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

示例11: setup_method

    def setup_method(self, _):
        import transaction
        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import Role
        from c2cgeoportal_commons.models.static import User

        r = Role(name="__test_role")
        u = User(
            username="__test_user", password="__test_user", role=r
        )

        DBSession.add_all([u, r])
        transaction.commit()
开发者ID:yjacolin,项目名称:c2cgeoportal,代码行数:13,代码来源:test_request_property.py

示例12: setup_method

    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 Theme, LayerGroup, Interface, LayerWMS, Metadata

        main = Interface(name="desktop")

        ogc_server, _ = create_default_ogcserver()

        layer_noscale = LayerWMS(name="__test_layer_noscale", public=True)
        layer_noscale.layer = "test_noscale"
        layer_noscale.interfaces = [main]
        layer_noscale.ogc_server = ogc_server

        layer_minscale = LayerWMS(name="__test_layer_minscale", public=True)
        layer_minscale.layer = "test_minscale"
        layer_minscale.interfaces = [main]
        layer_minscale.ogc_server = ogc_server

        layer_maxscale = LayerWMS(name="__test_layer_maxscale", public=True)
        layer_maxscale.layer = "test_maxscale"
        layer_maxscale.interfaces = [main]
        layer_maxscale.ogc_server = ogc_server

        layer_boothscale = LayerWMS(name="__test_layer_boothscale", public=True)
        layer_boothscale.layer = "test_boothscale"
        layer_boothscale.interfaces = [main]
        layer_boothscale.ogc_server = ogc_server

        layer_metadatascale = LayerWMS(name="__test_layer_metadatascale", public=True)
        layer_metadatascale.layer = "test_boothscale"
        layer_metadatascale.interfaces = [main]
        layer_metadatascale.ogc_server = ogc_server
        layer_metadatascale.metadatas = [
            Metadata("minResolution", "100"),
            Metadata("maxResolution", "1000"),
        ]

        layer_group = LayerGroup(name="__test_layer_group")
        layer_group.children = [layer_noscale, layer_minscale, layer_maxscale, layer_boothscale, layer_metadatascale]

        theme = Theme(name="__test_theme")
        theme.interfaces = [main]
        theme.children = [layer_group]

        DBSession.add_all([theme])

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

示例13: _import_layer_wmts

    def _import_layer_wmts(self, layer, messages):
        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import OGCServer

        layers = [d.value for d in layer.metadatas if d.name == "queryLayers"]
        if len(layers) == 0:
            layers = [d.value for d in layer.metadatas if d.name == "wmsLayer"]
        server = [d.value for d in layer.metadatas if d.name == "ogcServer"]
        if len(server) >= 1 and len(layers) >= 1:
            for wms_layer in layers:
                try:
                    db_server = DBSession.query(OGCServer).filter(OGCServer.name == server[0]).one()
                    self._import_layer_attributes(
                        db_server.url_wfs or db_server.url, wms_layer,
                        layer.item_type, layer.name, messages
                    )
                except NoResultFound:
                    print(colorize(
                        "ERROR! the OGC server '{}' from the WMTS layer '{}' does not exist.".format(
                            server[0], layer.name
                        ),
                        RED
                    ))
                    if os.environ.get("IGNORE_I18N_ERRORS", "FALSE") != "TRUE":
                        raise
开发者ID:yjacolin,项目名称:c2cgeoportal,代码行数:25,代码来源:lingua_extractor.py

示例14: test_private

 def test_private(self):
     from c2cgeoportal_commons.models import DBSession
     from c2cgeoportal_commons.models.static import User
     entry = self._create_entry_obj(params={
         "version": "2"
     }, user=DBSession.query(User).filter_by(username=u"__test_user").one())
     themes = entry.themes()
     self.assertEquals(themes["errors"], [])
     self.assertEquals(
         [self._only_name(t) for t in themes["themes"]],
         [{
             "name": u"__test_theme",
             "children": [{
                 "name": u"__test_layer_group",
                 "children": [{
                     "name": u"__test_layer_wms"
                 }, {
                     "name": u"__test_layer_wms_private"
                 }, {
                     "name": u"__test_layer_wmts"
                 }, {
                     "name": u"__test_layer_wmts_private"
                 }]
             }]
         }]
     )
开发者ID:yjacolin,项目名称:c2cgeoportal,代码行数:26,代码来源:test_themes_private.py

示例15: test_group_update

    def test_group_update(self):
        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import LayerGroup
        layer_group_3 = DBSession.query(LayerGroup).filter(LayerGroup.name == "__test_layer_group_3").one()
        layer_group_3.children = layer_group_3.children[:-1]
        transaction.commit()

        entry = self._create_entry_obj(params={
            "version": "2",
            "group": "__test_layer_group_3",
            "catalogue": "true",
        })
        themes = entry.themes()
        self.assertEqual(self._get_filtered_errors(themes), set())
        self.assertEqual(
            self._only_name(themes["group"]),
            {
                "name": "__test_layer_group_3",
                # order is important
                "children": [{
                    "name": "__test_layer_wmts"
                }, {
                    "name": "__test_layer_internal_wms"
                }]
            }
        )
开发者ID:yjacolin,项目名称:c2cgeoportal,代码行数:26,代码来源:test_themes.py


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