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


Python DBSession.delete方法代码示例

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


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

示例1: teardown_method

# 需要导入模块: from c2cgeoportal_commons.models import DBSession [as 别名]
# 或者: from c2cgeoportal_commons.models.DBSession import delete [as 别名]
    def teardown_method(self, _):
        testing.tearDown()

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import TreeItem, Interface, OGCServer

        for item in DBSession.query(TreeItem).all():
            DBSession.delete(item)
        DBSession.query(OGCServer).delete()
        DBSession.query(Interface).filter(
            Interface.name == "main"
        ).delete()

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

示例2: teardown_method

# 需要导入模块: from c2cgeoportal_commons.models import DBSession [as 别名]
# 或者: from c2cgeoportal_commons.models.DBSession import delete [as 别名]
    def teardown_method(self, _):
        testing.tearDown()

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import TreeItem, Interface, Metadata

        for t in DBSession.query(Metadata).all():
            DBSession.delete(t)
        for item in DBSession.query(TreeItem).all():
            DBSession.delete(item)
        DBSession.query(Interface).filter(
            Interface.name == "desktop"
        ).delete()

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

示例3: setup_method

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

        cleanup_db()

        self._tables = []

        import transaction
        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import Role, Interface, TreeItem, Theme, \
            LayerGroup, OGCSERVER_AUTH_NOAUTH
        from c2cgeoportal_commons.models.static import User

        for treeitem in DBSession.query(TreeItem).all():
            DBSession.delete(treeitem)

        self.role = Role(name="__test_role")
        self.user = User(
            username="__test_user",
            password="__test_user",
            role=self.role
        )
        self.main = Interface(name="main")

        self.ogc_server, external_ogc_server = create_default_ogcserver()
        self.ogc_server.auth = OGCSERVER_AUTH_NOAUTH
        external_ogc_server.auth = OGCSERVER_AUTH_NOAUTH

        self.metadata = None
        self.layer_ids = []

        self.layer_group_1 = LayerGroup(name="__test_layer_group_1")

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

        DBSession.add_all([self.main, self.user, self.role, theme, self.layer_group_1])

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

示例4: teardown_method

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

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

        ra = DBSession.query(RestrictionArea).filter(
            RestrictionArea.name == "__test_ra1"
        ).one()
        ra.roles = []
        ra.layers = []
        DBSession.delete(ra)

        r = DBSession.query(Role).filter(Role.name == "__test_role1").one()
        DBSession.delete(r)

        for layer in DBSession.query(LayerWMS).filter(
                LayerWMS.name.in_(["testpoint_group_name", "testpoint_protected_2_name"])
        ).all():
            DBSession.delete(layer)
        DBSession.query(Interface).filter(
            Interface.name == "main"
        ).delete()
        DBSession.query(OGCServer).delete()

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

示例5: clean

# 需要导入模块: from c2cgeoportal_commons.models import DBSession [as 别名]
# 或者: from c2cgeoportal_commons.models.DBSession import delete [as 别名]
    def clean():
        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.static import User
        from c2cgeoportal_commons.models.main import TreeItem, Interface, Role, RestrictionArea, OGCServer

        for o in DBSession.query(RestrictionArea).all():
            o.roles = []
            o.layers = []
            DBSession.delete(o)
        for item in DBSession.query(TreeItem).all():
            DBSession.delete(item)
        DBSession.query(OGCServer).delete()
        DBSession.query(Interface).filter(
            Interface.name == "main"
        ).delete()
        DBSession.query(User).filter(
            User.username == "__test_user"
        ).delete()
        DBSession.query(Role).filter(
            Role.name == "__test_role"
        ).delete()

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

示例6: teardown_method

# 需要导入模块: from c2cgeoportal_commons.models import DBSession [as 别名]
# 或者: from c2cgeoportal_commons.models.DBSession import delete [as 别名]
    def teardown_method(self, _):
        import transaction
        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import Role, Functionality, OGCServer
        from c2cgeoportal_commons.models.static import User

        functionality.FUNCTIONALITIES_TYPES = None

        transaction.commit()

        for o in DBSession.query(User).filter(
                User.username == "__test_user1").all():
            o.functionalities = []
            DBSession.delete(o)
        for o in DBSession.query(User).filter(
                User.username == "__test_user2").all():
            o.functionalities = []
            DBSession.delete(o)
        for o in DBSession.query(Role).filter(
                Role.name == "__test_role1").all():
            o.functionalities = []
            DBSession.delete(o)
        for o in DBSession.query(Role).filter(
                Role.name == "__test_role2").all():
            o.functionalities = []
            DBSession.delete(o)
        DBSession.query(Functionality).filter(
            Functionality.name == "__test_s").delete()
        DBSession.query(Functionality).filter(
            Functionality.name == "__test_a").delete()
        DBSession.query(Functionality).filter(
            Functionality.name == "__test_s").delete()
        DBSession.query(Functionality).filter(
            Functionality.name == "__test_a").delete()
        DBSession.query(OGCServer).delete()

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

示例7: teardown_method

# 需要导入模块: from c2cgeoportal_commons.models import DBSession [as 别名]
# 或者: from c2cgeoportal_commons.models.DBSession import delete [as 别名]
    def teardown_method(self, _):
        testing.tearDown()

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.main import Layer, Theme, LayerGroup, OGCServer, Interface

        for layer in DBSession.query(Layer).all():
            DBSession.delete(layer)
        for g in DBSession.query(LayerGroup).all():
            DBSession.delete(g)
        for t in DBSession.query(Theme).all():
            DBSession.delete(t)
        DBSession.query(OGCServer).delete()
        DBSession.query(Interface).filter(
            Interface.name == "main"
        ).delete()

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

示例8: main

# 需要导入模块: from c2cgeoportal_commons.models import DBSession [as 别名]
# 或者: from c2cgeoportal_commons.models.DBSession import delete [as 别名]
def main():
    parser = ArgumentParser(
        prog=sys.argv[0], add_help=True,
        description="Tool used to migrate your old layers from the old structure to the new one.",
    )

    parser.add_argument(
        "-i", "--app-config",
        default="geoportal/production.ini",
        dest="app_config",
        help="the application .ini config file (optional, default is 'production.ini')"
    )
    parser.add_argument(
        "-n", "--app-name",
        default="app",
        dest="app_name",
        help="the application name (optional, default is 'app')"
    )
    parser.add_argument(
        "--no-layers",
        dest="layers",
        action="store_false",
        help="do not import the layers"
    )
    parser.add_argument(
        "--no-groups",
        dest="groups",
        action="store_false",
        help="do not import the groups"
    )
    parser.add_argument(
        "--no-themes",
        dest="themes",
        action="store_false",
        help="do not import the themes"
    )
    options = parser.parse_args()

    app_config = options.app_config
    app_name = options.app_name
    if app_name is None and "#" in app_config:
        app_config, app_name = app_config.split("#", 1)
    fileConfig(app_config, defaults=os.environ)
    app = get_app(app_config, app_name, options=os.environ)

    # must be done only once we have loaded the project config
    from c2cgeoportal_commons.models import DBSession
    from c2cgeoportal_commons.models.main import OGCServer, Theme, LayerWMS, LayerWMTS, LayerV1, LayerGroup

    session = DBSession()

    if options.layers:
        table_list = [LayerWMTS, LayerWMS, OGCServer]
        for table in table_list:
            print(("Emptying table {0!s}.".format(table.__table__)))
            # must be done exactly this way otherwise the cascade config in the
            # models are not used
            for t in session.query(table).all():
                session.delete(t)

        # list and create all distinct ogc_server
        ogc_server(session, app.registry.settings)

        print("Converting layerv1.")
        for layer in session.query(LayerV1).all():
            layer_v1tov2(session, layer)

    if options.groups:
        print("Converting layer groups.")
        for group in session.query(LayerGroup).all():
            layergroup_v1tov2(session, group)

    if options.themes:
        print("Converting themes.")
        for theme in session.query(Theme).all():
            theme_v1tov2(session, theme)

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


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