python - TypeError: __init__() got an unexpected keyword argument 'parent' -


i building application in google app engine cloud datastore backend.

my model base class

from google.appengine.ext import ndb

class cfcmodel(ndb.model):     """     base model can inherit other models. test     """     created_date = ndb.datetimeproperty(auto_now=true)     modified_date = ndb.datetimeproperty(auto_now_add=true) 

the class model inherits

class praisereport(cfcmodel):     def __init__(self):         self.username = ndb.stringproperty(repeated=true)         self.report = ndb.stringproperty(required=true)         super(praisereport, self).__init__() 

i trying create object

key = praisereportrepository.get_praise_report_key() praise_report_model = praisereport(parent=key) praise_report_model.username = praise_report.username praise_report_model.report = praise_report.report praise_report_model.put() 

and following error

error    2016-05-25 09:34:59,882 app.py:1423] exception on /forms/add_praise_report [get] traceback (most recent call last):   file "/users/vinay/app-engine/cm-12/server/lib/flask/app.py", line 1817, in wsgi_app     response = self.full_dispatch_request()   file "/users/vinay/app-engine/cm-12/server/lib/flask/app.py", line 1477, in full_dispatch_request     rv = self.handle_user_exception(e)   file "/users/vinay/app-engine/cm-12/server/lib/flask/app.py", line 1381, in handle_user_exception     reraise(exc_type, exc_value, tb)   file "/users/vinay/app-engine/cm-12/server/lib/flask/app.py", line 1475, in full_dispatch_request     rv = self.dispatch_request()   file "/users/vinay/app-engine/cm-12/server/lib/flask/app.py", line 1461, in dispatch_request     return self.view_functions[rule.endpoint](**req.view_args)   file "/users/vinay/app-engine/cm-12/cfc/decorators/authentication.py", line 62, in authenticate_and_call_member     return func(*args, **kwargs)   file "/users/vinay/app-engine/cm-12/routes/praisereportroutes.py", line 34, in add_report     repo.add(report)   file "/users/vinay/app-engine/cm-12/cfc/data/praisereportrepository.py", line 12, in add     praise_report_model = praisereport(parent=key) typeerror: __init__() got unexpected keyword argument 'parent' 

there quite few errors here. main 1 have overridden __init__ method not accept parameters, trying call with parameters. obviously, subclass method should accept same parameters base class, , pass parameters super call - done *args, **kwargs.

however not should overriding __init__ @ here. code have in overridden method not belong there. fields must defined @ class level; not work if define them inside method. move fields out, , remove method altogether.

class praisereport(cfcmodel):     username = ndb.stringproperty(repeated=true)     report = ndb.stringproperty(required=true) 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -