Merge ~cjwatson/lazr.restful:remove-relative-import-hack into lazr.restful:main

Proposed by Colin Watson
Status: Merged
Merged at revision: 067f6c697543a1df20f3718646719bd269a658b1
Proposed branch: ~cjwatson/lazr.restful:remove-relative-import-hack
Merge into: lazr.restful:main
Diff against target: 21 lines (+2/-8)
1 file modified
src/lazr/restful/frameworks/django.py (+2/-8)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+413799@code.launchpad.net

Commit message

Remove relative import hack from lazr.restful.frameworks.django

Description of the change

It's no longer needed on Python 3, since that always uses absolute imports.

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

Looks good

Just curious - why do we not install Django for testing? Whenever Django decides to restructure its hiearachy / API, our tests will continue to pass, but the code will no longer work.

Who is using the Django integration?

review: Approve
Revision history for this message
Colin Watson (cjwatson) wrote :

SSO used it at one point (as indicated by https://bugs.launchpad.net/lazr.restful/+bug/640132), but no longer does. I'm afraid I have no idea who, if anyone, is using the Django integration at this point. This all long predates me, and since I don't really know its history or usage I've been hesitant to touch it more than necessary.

I've filed https://bugs.launchpad.net/lazr.restful/+bug/1956782 to consider removing this.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/lazr/restful/frameworks/django.py b/src/lazr/restful/frameworks/django.py
2index a7ae447..c3f9a85 100644
3--- a/src/lazr/restful/frameworks/django.py
4+++ b/src/lazr/restful/frameworks/django.py
5@@ -20,14 +20,8 @@ from zope.schema import getFieldsInOrder
6 from zope.traversing.browser.absoluteurl import AbsoluteURL
7
8 import grokcore.component
9-
10-# Without this trickery, this module (called "django") will mask the
11-# real Django modules. We could use "from __future__ import
12-# absolute_import", but that would not work with Python 2.4.
13-ObjectDoesNotExist = __import__(
14- "django.core.exceptions", {}
15-).core.exceptions.ObjectDoesNotExist
16-Manager = __import__("django.db.models.manager", {}).db.models.manager.Manager
17+from django.core.exceptions import ObjectDoesNotExist
18+from django.db.models.manager import Manager
19
20 from lazr.restful import directives # noqa: E402
21 from lazr.restful.interfaces import ( # noqa: E402

Subscribers

People subscribed via source and target branches