pinax-teams icon indicating copy to clipboard operation
pinax-teams copied to clipboard

pinax-teams middleware error

Open Tikam02 opened this issue 6 years ago • 7 comments

mw_instance = middleware(handler) TypeError: object() takes no parameters

File "/root/Desktop/pin/site/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 140, in init self.load_middleware() File "/root/Desktop/pin/site/lib/python3.6/site-packages/django/core/handlers/base.py", line 39, in load_middleware mw_instance = middleware(handler) TypeError: object() takes no parameters

Tikam02 avatar Mar 22 '18 20:03 Tikam02

Good catch @Tikam02, thanks.

pinax-teams is a Pinax app, but not part of the "official" apps seen by invoking pinax apps:

$ pinax apps
Release Application
------- ---------------
  2.0.3 django-user-accounts
  3.0.2 pinax-announcements
  7.0.1 pinax-blog
  2.0.4 pinax-calendars
  2.0.3 pinax-eventlog
  2.0.3 pinax-events
  3.0.1 pinax-images
  6.1.2 pinax-invitations
  3.0.1 pinax-likes
  2.0.2 pinax-messages
  2.0.3 pinax-news
  5.0.3 pinax-notifications
  4.0.0 pinax-stripe
  2.0.4 pinax-testimonials
  2.0.3 pinax-waitinglist
  4.0.2 pinax-webanalytics

Why is pinax-teams not an "official" Pinax app? Because pinax-teams has incomplete documentation and incomplete tests and is not yet fully compatible with Django v2.0.

In this particular case, it appears TeamMiddleware is designed for the old-style "MIDDLEWARE_CLASSES". It is not yet upgraded to Django v2.0 "MIDDLEWARE" nor is it using the "MiddlewareMixin" class. Furthermore, there are no tests proving the middleware works as intended.

We'd love your help @Tikam02 if you feel inclined to submit a PR with tests which fixes the problem. Thanks!

grahamu avatar Mar 22 '18 21:03 grahamu

Here's the test coverage for pinax-teams: https://codecov.io/gh/pinax/pinax-teams/tree/master/pinax/teams

@Tikam02 note middleware.py has 0% coverage. Apparently you're the first dev upgrading to the latest pinax-teams who is using TeamMiddleware with Django 2.0.

grahamu avatar Mar 23 '18 01:03 grahamu

@grahamu Thank you so much for the information and guidance. Sure I'll do PR once i solved some of the issues and after my project i want to contribute to fix pinax issues.It's really an awesome framework. So, should i wait for the updates or your code from the above link provided will work.Because i need this app, hosting team event for my site.

Tikam02 avatar Mar 23 '18 05:03 Tikam02

@Tikam02 Thanks for your PR offer! We're always happy for community help.

Preferably convert TeamMiddleware to new-style MIDDLEWARE.

I'm not sure what you mean by "the above link provided" as the only link I've provided in this story shows test coverage.

There is no planned update to pinax-teams at the moment so don't wait for us!

grahamu avatar Mar 23 '18 06:03 grahamu

@Tikam02 one more thought... in order to move forward on your project, perhaps updating TeamMiddleware to inherit from the MiddlewareMixin class is a good short-term solution. Again PRs welcome!

grahamu avatar Mar 23 '18 17:03 grahamu

Sure i'll try and again Thanks for the Information.

Tikam02 avatar Mar 23 '18 20:03 Tikam02

To work around this issue you can create the following class:

from django.utils.deprecation import MiddlewareMixin
from pinax.teams.middleware import TeamMiddleware

class CompatibleTeamMiddleware(MiddlewareMixin, TeamMiddleware):
    pass

And then point to it instead of the original middleware. For example:

MIDDLEWARE = [
    # ....
    'myapp.middleware.CompatibleTeamMiddleware',
]

kichik avatar Oct 30 '21 21:10 kichik