delete() 恰好接受 2 个参数(给定 0 个)- Google App Engine 数据存储区删除

delete() takes exactly 2 arguments (0 given) - Google App Engine Datastore Delete

我有一个事件 table,字段为:

class Event(db.Model):
    """
    Event Model
    """

    account = db.UserProperty(required=True)
    event_id = db.StringProperty(required=True)

这里是删除函数:

@staticmethod
def delete(account,
           event_id):
    """Delete Event by event_id
    Args:
        account     - account
        event_id    - event_id
    Raises:
        None
    """
    if account is not None and event_id is not None:
        event = Event.find_by_account_and_event_id(account, event_id)

        # if a valid event
        if event is not None:
            logging.info('DELETING event with event_id = ' + event.event_id + ' account= ' + str(event.account))
            event.delete()

我看到以下错误:

2016-06-15 15:45:45.180 DELETING event with event_id = 2a5e5422-dec5-4e87-a462-e2551e3f3cf8 account= test.user
E 2016-06-15 15:45:45.186 delete() takes exactly 2 arguments (0 given)

仅供参考:这是来自 app.yaml:

version: 1
runtime: python27
threadsafe: true
api_version: 1

我不确定这里出了什么问题。有什么想法吗?

我很确定你覆盖了删除方法,因为从数据库中删除没有任何参数。可能不会被覆盖,但您没有在 db.Model class

中调用删除
In [51]: class X(db.Model):
             pass 
In [52]: x = X() 
In [53]: x.put() 
Out[53]: datastore_types.Key.from_path(u'X', 6052396701319168L, _app=u's~<removed>') 
In [54]: x.delete()