mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
Removed django.contrib.gis.geoip2.GeoIP2.open() per deprecation timeline.
This commit is contained in:
parent
4104dafdf3
commit
8d695bf510
@ -14,13 +14,11 @@ directory corresponding to settings.GEOIP_PATH.
|
|||||||
|
|
||||||
import ipaddress
|
import ipaddress
|
||||||
import socket
|
import socket
|
||||||
import warnings
|
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core.validators import validate_ipv46_address
|
from django.core.validators import validate_ipv46_address
|
||||||
from django.utils._os import to_path
|
from django.utils._os import to_path
|
||||||
from django.utils.deprecation import RemovedInDjango60Warning
|
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
|
|
||||||
__all__ = ["HAS_GEOIP2"]
|
__all__ = ["HAS_GEOIP2"]
|
||||||
@ -230,12 +228,3 @@ class GeoIP2:
|
|||||||
from django.contrib.gis.geos import Point
|
from django.contrib.gis.geos import Point
|
||||||
|
|
||||||
return Point(self.lon_lat(query), srid=4326)
|
return Point(self.lon_lat(query), srid=4326)
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def open(cls, full_path, cache):
|
|
||||||
warnings.warn(
|
|
||||||
"GeoIP2.open() is deprecated. Use GeoIP2() instead.",
|
|
||||||
RemovedInDjango60Warning,
|
|
||||||
stacklevel=2,
|
|
||||||
)
|
|
||||||
return GeoIP2(full_path, cache)
|
|
||||||
|
@ -99,18 +99,6 @@ Keyword Arguments Description
|
|||||||
Methods
|
Methods
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Instantiating
|
|
||||||
-------------
|
|
||||||
|
|
||||||
.. classmethod:: GeoIP2.open(path, cache)
|
|
||||||
|
|
||||||
This classmethod instantiates the GeoIP object from the given database path
|
|
||||||
and given cache setting.
|
|
||||||
|
|
||||||
.. deprecated:: 5.1
|
|
||||||
|
|
||||||
Use the :class:`GeoIP2()` constructor instead.
|
|
||||||
|
|
||||||
Querying
|
Querying
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
@ -307,3 +307,5 @@ to remove usage of these features.
|
|||||||
``django.utils.itercompat`` module is removed.
|
``django.utils.itercompat`` module is removed.
|
||||||
|
|
||||||
* The ``django.contrib.gis.geoip2.GeoIP2.coords()`` method is removed.
|
* The ``django.contrib.gis.geoip2.GeoIP2.coords()`` method is removed.
|
||||||
|
|
||||||
|
* The ``django.contrib.gis.geoip2.GeoIP2.open()`` method is removed.
|
||||||
|
@ -7,7 +7,6 @@ from django.conf import settings
|
|||||||
from django.contrib.gis.geoip2 import HAS_GEOIP2
|
from django.contrib.gis.geoip2 import HAS_GEOIP2
|
||||||
from django.contrib.gis.geos import GEOSGeometry
|
from django.contrib.gis.geos import GEOSGeometry
|
||||||
from django.test import SimpleTestCase, override_settings
|
from django.test import SimpleTestCase, override_settings
|
||||||
from django.utils.deprecation import RemovedInDjango60Warning
|
|
||||||
|
|
||||||
if HAS_GEOIP2:
|
if HAS_GEOIP2:
|
||||||
import geoip2
|
import geoip2
|
||||||
@ -201,13 +200,6 @@ class GeoLite2Test(SimpleTestCase):
|
|||||||
version = f"{m.binary_format_major_version}.{m.binary_format_minor_version}"
|
version = f"{m.binary_format_major_version}.{m.binary_format_minor_version}"
|
||||||
self.assertEqual(repr(g), f"<GeoIP2 [v{version}] _path='{g._path}'>")
|
self.assertEqual(repr(g), f"<GeoIP2 [v{version}] _path='{g._path}'>")
|
||||||
|
|
||||||
def test_open_deprecation_warning(self):
|
|
||||||
msg = "GeoIP2.open() is deprecated. Use GeoIP2() instead."
|
|
||||||
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
|
|
||||||
g = GeoIP2.open(settings.GEOIP_PATH, GeoIP2.MODE_AUTO)
|
|
||||||
self.assertTrue(g._reader)
|
|
||||||
self.assertEqual(ctx.filename, __file__)
|
|
||||||
|
|
||||||
|
|
||||||
@skipUnless(HAS_GEOIP2, "GeoIP2 is required.")
|
@skipUnless(HAS_GEOIP2, "GeoIP2 is required.")
|
||||||
@override_settings(
|
@override_settings(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user