简体   繁体   English

AttributeError:“驱动程序”对象没有属性“ id”

[英]AttributeError: 'Driver' object has no attribute 'id'

i have a deployment on appengine, im getting this error when i'm tryng to assign a trip 我在appengine上进行了部署,我在尝试分配行程时收到此错误

def get(self):
    from trips.end_trip import notify_cancelation
    """
    GET /2/drivers/report_trip_arrival
    >  trip_id /custom_id
    > device_id
    > driver_id
    > event_timestamp
    <  200 application/json
    Changes the trip status to 4, your taxi has arrived
    """
    responseJSON = {}
    self.response.headers['Content-Type'] = "application/json"
    trip_id = self.request.get("trip_id")
    custom_trip_id = self.request.get("custom_id")
    device_id = self.request.get("device_id")

    logging.info("Report arrival")
    logging.info(str(trip_id))
    logging.info(str(custom_trip_id))
    logging.info(str(device_id))

    #Get the trip
    # fixing
    try:
        trip = trip_finder.find_trip(trip_id=trip_id, custom_id=custom_trip_id)
    except:
        trip = None
        responseJSON["Status"] = "OK"
        return

    driver_id = self.request.get('driver_id')
    if driver_id:
        driver_id = int(driver_id)
        if trip.selected_driver.get().id() != driver_id:
            responseJSON = {'status': 'OK', 'Staus': 'OK'}
            json.dump(responseJSON, self.response.out)
            return

    if trip:
        #deferred.defer(notify_arrival, trip.key.id(), _queue="delivery")
        params = {}
        params["trip_id"] = trip.key.id()
        taskqueue.add(url="/2/delivery/task/notify_arrival", params=params, queue_name="delivery")

        last_status = trip.last_status()

        #If we are already on status 4, we just return OK
        if last_status.id != "4":
            #Update the status
            #ripStatus(trip=trip.key, id="4", message=trip_statuses["4"], timestamp=now()).put()
            trip.change_status("4")
            #Alert the passenger
            name = trip.traveler_name.split()[0] if trip.traveler_name else ""
            message_status = name + ", ha llegado tu taxi :)"
        responseJSON["Status"] = "OK"
        responseJSON["status"] = "OK"
        # if the trip was canceled notify the driver
        if last_status.id == "16":
            #deferred.defer(notify_cancelation, trip.key.id(), _queue="endtrip")
            params = {'trip_id': trip.key.id()}
            taskqueue.add(url="/2/trips/task/notify_cancelation", params=params, queue_name="endtrip")
            #deferred.defer(notify_cancelation, trip.key.id(), _queue="endtrip")
    else:
        responseJSON["Status"] = "OK"
        responseJSON["status"] = "OK"

    self.response.out.write(json.dumps(responseJSON))

This is the full details: 这是完整的详细信息:

Traceback (most recent call last):
 File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
   return method(*args, **kwargs)
 File "/base/data/home/apps/s~precise-line-762/v-4-4-03.383164018327881359/security/security.py", line 47, in wrapper
   return handler(request)
 File "/base/data/home/apps/s~precise-line-762/v-4-4-03.383164018327881359/drivers/handlers.py", line 141, in get
   if trip.selected_driver.get().id() != driver_id:
 File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/model.py", line 3640, in __getattr__
   return super(Expando, self).__getattribute__(name)
AttributeError: 'Driver' object has no attribute 'id'

You have to pick object's ID from key property. 您必须从属性中选择对象的ID

Looks like your trip.selected_driver is a Key already. 看起来像您的trip.selected_driver已经是钥匙。 If you want to ensure the object exist then call trip.selected_driver.get().key.id() 如果要确保对象存在,请调用trip.selected_driver.get().key.id()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python-Selenium Web驱动程序错误-self._driver.execute-AttributeError:“ unicode”对象没有属性“ id” - Python - Selenium Web Driver error - self._driver.execute - AttributeError: 'unicode' object has no attribute 'id' AttributeError:“WebElement”object 没有属性“驱动程序” - AttributeError: 'WebElement' object has no attribute 'driver' AttributeError:&#39;LoginPage&#39;对象没有属性&#39;driver&#39; - AttributeError: 'LoginPage' object has no attribute 'driver' AttributeError:&#39;TestLogin&#39;对象没有属性&#39;driver&#39; - AttributeError: 'TestLogin' object has no attribute 'driver' AttributeError: 'WebDriver' object 没有属性 'driver' - AttributeError: 'WebDriver' object has no attribute 'driver' AttributeError: 'TestTomsLogin' object 没有属性 'driver' - AttributeError: 'TestTomsLogin' object has no attribute 'driver' AttributeError“列表”对象没有属性“ id” - AttributeError 'list' object has no attribute 'id' AttributeError:“ ParseResult”对象没有属性“ id” - AttributeError: 'ParseResult' object has no attribute 'id' SQLAlchemy:AttributeError:“表”对象没有属性“ id” - SQLAlchemy: AttributeError: 'Table' object has no attribute 'id' AttributeError: 'NoneType' object 没有属性 '_id' - AttributeError: 'NoneType' object has no attribute '_id'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM