Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecation indicator for URLs when using JSON format. #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alkanen
Copy link
Collaborator

@alkanen alkanen commented Jul 15, 2020

Based on release 3.0.2 rather than on HEAD.

@alkanen alkanen requested review from lithammer, jonashagberg, twiden and a user July 15, 2020 10:51
@alkanen
Copy link
Collaborator Author

alkanen commented Jul 15, 2020

My plan is to make a tag from this rather than to merge it to master since it's based on 3.0.2. At least I think that makes sense?

Copy link

@twiden twiden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be something that we need to redo or maintain if we upgrade django in the future?

@@ -121,7 +121,12 @@ def handle(self, *args, **options):
raise CommandError("Error occurred while trying to load %s: %s" % (getattr(settings, urlconf), str(e)))

view_functions = self.extract_views_from_urlpatterns(urlconf.urlpatterns)
for (func, regex, url_name) in view_functions:
for (func, regex, url_name, *deprecated) in view_functions:
if deprecated:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks odd... Is deprecated sometimes a bool and sometimes a list? If so it is better to check the type than a boolean check. Best would be if it is always same type though...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, no... The problem is that I've re-used the name. I'll rename some of them to make it clearer.

@alkanen alkanen force-pushed the add-deprecation-on-3.0.2 branch from dedb1ed to 4ef7af2 Compare July 15, 2020 12:47
@@ -203,6 +208,7 @@ def extract_views_from_urlpatterns(self, urlpatterns, base='', namespace=None):
"""
views = []
for p in urlpatterns:
deprecated = False
Copy link

@twiden twiden Jul 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value has two defaults. this is 1

@@ -211,8 +217,12 @@ def extract_views_from_urlpatterns(self, urlpatterns, base='', namespace=None):
name = '{0}:{1}'.format(namespace, p.name)
else:
name = p.name
deprecated = getattr(p, "deprecated", False)
Copy link

@twiden twiden Jul 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value has two defaults. this is 2

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. That's what I get for refactoring :)

@alkanen
Copy link
Collaborator Author

alkanen commented Jul 15, 2020

Will this be something that we need to redo or maintain if we upgrade django in the future?

Possibly, but this is a third party library and not part of the main django installation. Before this, we didn't even install it in our environment. As long as the "show_urls" part of django-extensions is still compatible with our django installation, we'll have no problems and I don't think that will happen extremely often. Plus, this change is small so it's pretty easy to just grab the latest compatible django-extensions and add it back in.

However, Peter suggested that I send this upstream in a PR and ask if they'd be interested in adding it so we don't have to bother in the future.

@alkanen alkanen force-pushed the add-deprecation-on-3.0.2 branch from 4ef7af2 to 1307e7c Compare July 15, 2020 12:55
@alkanen alkanen removed the request for review from lithammer February 24, 2023 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants