python - Error: object.__new__() takes no parameters -
i'm getting following message, this use work before. have removed .delay function below generate message task looks processrequests.delay.(batch)
object._new_() takes no parameters
if request.method == 'post': batches = batch.objects.for_user_pending(request.user) batch in batches: processrequests(batch) #processrequests.delay used here batch.complete_update()
task:
class processrequests(task): name = "request process" max_retries = 1 default_retry_delay = 3 def run(self, batch): e in contact.objects.filter(contact_owner=batch.user, group=batch.group): msg = message.objects.create( recipient_number=e.mobile, content=batch.content, sender=e.contact_owner, billee=batch.user, sender_name=batch.sender_name ) gateway = gateway.objects.get(pk=2) msg.send(gateway)
full error:
environment: request method: post request url: http://127.0.0.1:8000/sms/process django version: 1.5.1 python version: 2.7.2 installed applications: ('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.humanize', 'south', 'sms', 'debug_toolbar') installed middleware: ('django.middleware.common.commonmiddleware', 'django.contrib.sessions.middleware.sessionmiddleware', 'django.middleware.csrf.csrfviewmiddleware', 'django.contrib.auth.middleware.authenticationmiddleware', 'django.contrib.messages.middleware.messagemiddleware', 'async_messages.middleware.asyncmiddleware', 'debug_toolbar.middleware.debugtoolbarmiddleware') traceback: file "/users/user/documents/workspace/s/django-env/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 115. response = callback(request, *callback_args, **callback_kwargs) file "/users/user/documents/workspace/s/django-env/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view 25. return view_func(request, *args, **kwargs) file "/users/user/documents/workspace/s/sms/views.py" in process_all 214. processrequests(batch) exception type: typeerror @ /sms/process exception value: object.__new__() takes no parameters
it looks you're trying instantiate processrequests
class parameters, class doesn't have constructor takes parameters, hence error.
i think need change...
processrequests(batch)
...to...
processrequests().run(batch)
...but whether want depends on definition of task
class.