question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Permissions: has_permission() takes 3 positional arguments but 4 were given

See original GitHub issue

I am getting this error after I updated the package

2017-06-01 02:16:22,002 - ERROR - worker - Error processing message with consumer faceoff_api.routing.APIDemultiplexer:
Traceback (most recent call last):
  File "/Users/coreytrombley/.envs/faceoff_venv/lib/python3.5/site-packages/channels/worker.py", line 119, in run
    consumer(message, **kwargs)
  File "/Users/coreytrombley/.envs/faceoff_venv/lib/python3.5/site-packages/channels/generic/base.py", line 32, in __init__
    self.dispatch(message, **kwargs)
  File "/Users/coreytrombley/.envs/faceoff_venv/lib/python3.5/site-packages/channels/generic/base.py", line 70, in dispatch
    return self.get_handler(message, **kwargs)(message, **kwargs)
  File "/Users/coreytrombley/.envs/faceoff_venv/lib/python3.5/site-packages/channels/generic/websockets.py", line 154, in raw_receive
    self.receive(self.decode_json(message['text']), **kwargs)
  File "/Users/coreytrombley/.envs/faceoff_venv/lib/python3.5/site-packages/channels/generic/websockets.py", line 266, in receive
    consumer(self.message, **kwargs)
  File "/Users/coreytrombley/.envs/faceoff_venv/lib/python3.5/site-packages/channels/binding/base.py", line 240, in consumer
    handler(message, **kwargs)
  File "/Users/coreytrombley/.envs/faceoff_venv/lib/python3.5/site-packages/channels/sessions.py", line 78, in inner
    return func(*args, **kwargs)
  File "/Users/coreytrombley/.envs/faceoff_venv/lib/python3.5/site-packages/channels/auth.py", line 42, in inner
    return func(message, *args, **kwargs)
  File "/Users/coreytrombley/.envs/faceoff_venv/lib/python3.5/site-packages/channels/binding/websockets.py", line 90, in trigger_inbound
    super(WebsocketBinding, cls).trigger_inbound(message, **kwargs)
  File "/Users/coreytrombley/.envs/faceoff_venv/lib/python3.5/site-packages/channels/binding/base.py", line 222, in trigger_inbound
    self.run_action(self.action, self.pk, self.data)
  File "/Users/coreytrombley/.envs/faceoff_venv/lib/python3.5/site-packages/channels_api/bindings.py", line 145, in run_action
    if not self.has_permission(self.user, action, pk):
  File "/Users/coreytrombley/.envs/faceoff_venv/lib/python3.5/site-packages/channels_api/bindings.py", line 111, in has_permission
    if not cls().has_permission(user, action, pk):
TypeError: has_permission() takes 3 positional arguments but 4 were given

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
linuxlewiscommented, Jun 2, 2017

To filter the create messages you will need to put the users in a group that is scoped to their user instead of the resource. This can be accomplished by implementing the method _group_name(self, action, id=None) on your binding class to return a string unique to that resource and user. Here’s a rough idea

from channels_api.bindings import ResourceBinding

class MyBinding(ResourceBinding):

     def _group_name(self, action, id=None):
           if action == "create":
                  return "{}-{}-{}".format(self.model_label, action, user_id)

1reaction
linuxlewiscommented, Jun 1, 2017

Hi there, what version of channels are you using? Can you share a form of your binding class? Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve error "object_permission() takes 3 positional ...
When I run my code, I get an error message saying that I am using too many positional arguments. TypeError: has_object_permission() takes 3...
Read more >
How to resolve error "object_permission() takes 3 positional ...
Coding example for the question How to resolve error "object_permission() takes 3 positional arguments but 4 were given"?-django.
Read more >
has_add_permission() takes 2 positional arguments but 3 ...
Support for `InlineModelAdmin.has_add_permission()` methods that don't accept `obj` as the second positional argument was deprecated in Django
Read more >
has_add_permission() takes 2 positional arguments but 3 ...
has_add_permission() takes 2 positional arguments but 3 were given. ... obj=None): inline_instances = [] for inline_class in self.get_inlines(request, ...
Read more >
takes 3 positional arguments but 4 were given | SmartAPI Forum
Hi @piidus ,. Please use the following command to upgrade to the latest python release pip install smartapi-python --upgrade.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found