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


Python State.delete方法代码示例

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


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

示例1: tearDown

# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
 def tearDown(self):
     #delete all from users
     PlaceBook.delete().execute()
     Place.delete().execute()
     User.delete().execute()
     City.delete().execute()
     State.delete().execute()
开发者ID:johnSerrano,项目名称:airbnb_clone,代码行数:9,代码来源:place_book.py

示例2: setUp

# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
 def setUp(self):
     #connect to db and delete everyone in the users table
     PlaceBook.delete().execute()
     Place.delete().execute()
     User.delete().execute()
     City.delete().execute()
     State.delete().execute()
开发者ID:johnSerrano,项目名称:airbnb_clone,代码行数:9,代码来源:place_book.py

示例3: handle_state_id

# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
def handle_state_id(state_id):
    '''Select the state with the id from the database and store as the variable
    `state` with a GET request method. Update the data of the particular state
    with a PUT request method. This will take the parameters passed and update
    only those values. Remove the state with this id from the database with
    a DELETE request method.

    Keyword arguments:
    state_id: The id of the state from the database.
    '''
    try:
        state = State.select().where(State.id == state_id).get()
    except State.DoesNotExist:
        return jsonify(msg="There is no state with this id."), 404

    if request.method == 'GET':
        return jsonify(state.to_dict()), 200

    elif request.method == 'DELETE':
        try:
            state = State.delete().where(State.id == state_id)
        except State.DoesNotExist:
            raise Exception("There is no state with this id.")
        state.execute()
        return jsonify(msg="State deleted successfully."), 200
开发者ID:Siphan,项目名称:airbnb_clone,代码行数:27,代码来源:state.py

示例4: del_state

# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
def del_state(id):
    id_check = State.select().where(State.id == id)
    if not id_check:
        return {'code': 404, 'msg': 'State not found'}, 404

    item = State.delete().where(State.id == id)
    item.execute()
    return {'code': 200, 'msg': 'Deleted successfully'}, 200
开发者ID:havk64,项目名称:airbnb_clone,代码行数:10,代码来源:state.py

示例5: delete_state

# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
def delete_state(state_id):
    """
    Delete the given state
    Deletes the given state in the database.
    ---
    tags:
        - State
    parameters:
        -
            in: path
            name: state_id
            type: string
            required: True
            description: ID of the state
    responses:
        200:
            description: State deleted successfully
            schema:
                $ref: '#/definitions/delete_amenity_delete_delete_200'
        404:
            description: State was not found
        500:
            description: Request could not be processed
    """
    try:
        ''' Check that state_id exists '''
        query = State.select().where(State.id == state_id)
        if not query.exists():
            raise LookupError('state_id')

        ''' Delete the given state '''
        delete_state = State.delete().where(State.id == state_id)
        delete_state.execute()
        response = {}
        response['code'] = 200
        response['msg'] = "State account was deleted"
        return response, 200
    except LookupError as e:
        abort(404)
    except Exception as error:
        abort(500)
开发者ID:rickharris-dev,项目名称:airbnb_clone,代码行数:43,代码来源:state.py

示例6: setUp

# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
 def setUp(self):
     #connect to db and delete everyone in the cities table
     City.delete().execute()
     State.delete().execute()
开发者ID:Praylin,项目名称:airbnb_clone,代码行数:6,代码来源:city.py

示例7: tearDown

# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
 def tearDown(self):
     #delete all from cities
     City.delete().execute()
     State.delete().execute()
开发者ID:Praylin,项目名称:airbnb_clone,代码行数:6,代码来源:city.py

示例8: setUp

# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
 def setUp(self):
     #connect to db and delete everyone in the states table
     State.delete().execute()
开发者ID:Praylin,项目名称:airbnb_clone,代码行数:5,代码来源:state.py

示例9: tearDown

# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
 def tearDown(self):
     #delete all from states
     State.delete().execute()
开发者ID:Praylin,项目名称:airbnb_clone,代码行数:5,代码来源:state.py

示例10: tearDown

# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
 def tearDown(self):
     #delete all from places
     Place.delete().execute()
     User.delete().execute()
     City.delete().execute()
     State.delete().execute()
开发者ID:johnSerrano,项目名称:airbnb_clone,代码行数:8,代码来源:place.py


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