flask-allows icon indicating copy to clipboard operation
flask-allows copied to clipboard

Expands wants request to class, removes request from classes

Open justanr opened this issue 6 years ago • 5 comments
trafficstars

Considering just making this the 1.0 release.

Expands wants_request to also work on subclasses of Requirement rather than just functions:

from flask_allows.requirements import wants_request

@wants_request
class OldKindOfRequirement(Requirement):
    def fulfill(self, user, request):
        return True

This adds a __call__ method at the front of the MRO that accepts user and request.

In combination with this change, Requirement.__call__ has been changed to only accept user. This change includes conditional requirements, which now only accept user but still use _call_requirement under the hood to compensate for functions and classes that still expect request to be passed but haven't been decorated with wants_request

wants_request will also become a permanent member of the public API since injecting the request into requirements is still useful for some instances and not having to depend on it statically is nice. _call_requirement will removed in the 1.0 release in place of wants_request

justanr avatar Apr 28 '19 16:04 justanr

Pull Request Test Coverage Report for Build 253

  • 23 of 23 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 97.317%

Totals Coverage Status
Change from base Build 221: 0.1%
Covered Lines: 337
Relevant Lines: 343

💛 - Coveralls

coveralls avatar Apr 28 '19 17:04 coveralls

Any chance to get this PR merged and a new version pushed to PyPI? :-)

sh4nks avatar May 22 '19 19:05 sh4nks

Sorry to be so radio silent on this. There's been a lot going on in my personal life that's blocked this from being merged. It'll be the beginning/middle of July before I can get back to this.

Sorry guys.

justanr avatar Jun 01 '19 22:06 justanr

Any chance for this to get merged and v1 being pushed to PyPI? :)

DonDebonair avatar Apr 16 '20 15:04 DonDebonair

ping @justanr

sh4nks avatar Jun 04 '20 17:06 sh4nks