當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。