pinax/pinax-teams

pinax-teams middleware error

Opened this issue · 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

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!

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 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 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!

@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!

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

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',
]