當前位置: 首頁>>代碼示例>>Python>>正文


Python City.delete方法代碼示例

本文整理匯總了Python中app.models.city.City.delete方法的典型用法代碼示例。如果您正苦於以下問題:Python City.delete方法的具體用法?Python City.delete怎麽用?Python City.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app.models.city.City的用法示例。


在下文中一共展示了City.delete方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: tearDown

# 需要導入模塊: from app.models.city import City [as 別名]
# 或者: from app.models.city.City 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.city import City [as 別名]
# 或者: from app.models.city.City 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_city_id

# 需要導入模塊: from app.models.city import City [as 別名]
# 或者: from app.models.city.City import delete [as 別名]
def handle_city_id(state_id, city_id):
    '''Select the city with the id from the database and store as the variable
    `city` with a GET request method. Remove the city with this id from the
    database with a DELETE request method.

    Keyword arguments:
    state_id: The state of the city from the database.
    city_id: The id of the city from the database.
    '''
    try:
        city = City.select().where((City.id == city_id) &
                                   (City.state == state_id)
                                   ).get()
    except City.DoesNotExist:
        raise jsonify(msg="There is no city with this id in this state."), 400

    if request.method == 'GET':
        return jsonify(city.to_dict())

    elif request.method == 'DELETE':
        try:
            city = City.delete().where((City.id == city_id) &
                                       (City.state == state_id))
        except City.DoesNotExist:
            raise Exception("There is no city with this id, in this state.")
        city.execute()
        return jsonify(msg="City deleted successfully."), 200
開發者ID:Siphan,項目名稱:airbnb_clone,代碼行數:29,代碼來源:city.py

示例4: delete_city

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

        ''' Check if city exists '''
        query = City.select().where(City.id == city_id)
        if not query.exists():
            raise LookupError('city_id')

        ''' Delete the city from the given state '''
        delete_city = City.delete().where(City.id == city_id, City.state == state_id)
        delete_city.execute()
        response = {}
        response['code'] = 200
        response['msg'] = "City account was deleted"
        return response, 200
    except LookupError as e:
        abort(404)
    except Exception as e:
        abort(500)
開發者ID:rickharris-dev,項目名稱:airbnb_clone,代碼行數:54,代碼來源:city.py

示例5: setUp

# 需要導入模塊: from app.models.city import City [as 別名]
# 或者: from app.models.city.City 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

示例6: tearDown

# 需要導入模塊: from app.models.city import City [as 別名]
# 或者: from app.models.city.City import delete [as 別名]
 def tearDown(self):
     #delete all from cities
     City.delete().execute()
     State.delete().execute()
開發者ID:Praylin,項目名稱:airbnb_clone,代碼行數:6,代碼來源:city.py

示例7: tearDown

# 需要導入模塊: from app.models.city import City [as 別名]
# 或者: from app.models.city.City 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.city.City.delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。