Search code examples
google-app-enginegoogle-cloud-datastoredelete-rowgqlgqlquery

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


I have an Event table with fields:

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

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

Here is the delete function:

@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()

I see the following error:

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)

FYI: This is from app.yaml:

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

I am not sure what's wrong here. Any thoughts?


Solution

  • I'm pretty sure you override the delete method, because the delete from db does not have any param. May not be override but you're not calling the delete in the 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()