[Python-modules-commits] [python-django-netfields] 01/01: New upstream version 0.8

Michael Fladischer fladi at moszumanska.debian.org
Mon Dec 18 17:37:36 UTC 2017


This is an automated email from the git hooks/post-receive script.

fladi pushed a commit to branch upstream
in repository python-django-netfields.

commit b658bf5c6f5f60b7f6bc177a9c92c03f50363352
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date:   Mon Dec 18 18:28:29 2017 +0100

    New upstream version 0.8
---
 CHANGELOG                          |  3 ++
 PKG-INFO                           |  3 +-
 django_netfields.egg-info/PKG-INFO |  3 +-
 netfields/fields.py                | 21 ++++++++++-
 netfields/forms.py                 | 27 ++------------
 netfields/managers.py              | 72 +-------------------------------------
 setup.cfg                          |  1 -
 setup.py                           |  3 +-
 8 files changed, 32 insertions(+), 101 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index ae4d6a4..eccba8f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+- 0.8
+  * Added support for Django 2.0
+
 - 0.7.2
   * Fix issue where prefetch_related returns empty querysets (Jay McEntire)
   * Improve validation error messages to include the underlying error (Diego
diff --git a/PKG-INFO b/PKG-INFO
index 7c2d33c..21f9fe8 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,11 +1,12 @@
 Metadata-Version: 1.1
 Name: django-netfields
-Version: 0.7.2
+Version: 0.8
 Summary: Django PostgreSQL netfields implementation
 Home-page: https://github.com/jimfunk/django-postgresql-netfields
 Author: James Oakley
 Author-email: jfunk at funktronics.ca
 License: BSD
+Description-Content-Type: UNKNOWN
 Description: Django PostgreSQL Netfields
         ===========================
         
diff --git a/django_netfields.egg-info/PKG-INFO b/django_netfields.egg-info/PKG-INFO
index 7c2d33c..21f9fe8 100644
--- a/django_netfields.egg-info/PKG-INFO
+++ b/django_netfields.egg-info/PKG-INFO
@@ -1,11 +1,12 @@
 Metadata-Version: 1.1
 Name: django-netfields
-Version: 0.7.2
+Version: 0.8
 Summary: Django PostgreSQL netfields implementation
 Home-page: https://github.com/jimfunk/django-postgresql-netfields
 Author: James Oakley
 Author-email: jfunk at funktronics.ca
 License: BSD
+Description-Content-Type: UNKNOWN
 Description: Django PostgreSQL Netfields
         ===========================
         
diff --git a/netfields/fields.py b/netfields/fields.py
index 2f908c9..6e5b135 100644
--- a/netfields/fields.py
+++ b/netfields/fields.py
@@ -1,5 +1,6 @@
 from django.core.exceptions import ValidationError
 from django.db import models
+from django.db.backends.postgresql_psycopg2.base import DatabaseWrapper
 from django.utils.six import with_metaclass, text_type
 from ipaddress import ip_interface, ip_network
 from netaddr import EUI
@@ -7,10 +8,28 @@ from netaddr.core import AddrFormatError
 
 from netfields.forms import InetAddressFormField, CidrAddressFormField, MACAddressFormField
 from netfields.mac import mac_unix_common
-from netfields.managers import NET_OPERATORS, NET_TEXT_OPERATORS
 from netfields.psycopg2_types import Inet, Macaddr
 
 
+NET_OPERATORS = DatabaseWrapper.operators.copy()
+
+for operator in ['contains', 'startswith', 'endswith']:
+    NET_OPERATORS[operator] = 'ILIKE %s'
+    NET_OPERATORS['i%s' % operator] = 'ILIKE %s'
+
+NET_OPERATORS['iexact'] = NET_OPERATORS['exact']
+NET_OPERATORS['regex'] = NET_OPERATORS['iregex']
+NET_OPERATORS['net_contained'] = '<< %s'
+NET_OPERATORS['net_contained_or_equal'] = '<<= %s'
+NET_OPERATORS['net_contains'] = '>> %s'
+NET_OPERATORS['net_contains_or_equals'] = '>>= %s'
+NET_OPERATORS['net_overlaps'] = '&& %s'
+NET_OPERATORS['max_prefixlen'] = '%s'
+NET_OPERATORS['min_prefixlen'] = '%s'
+
+NET_TEXT_OPERATORS = ['ILIKE %s', '~* %s']
+
+
 class _NetAddressField(models.Field):
     empty_strings_allowed = False
 
diff --git a/netfields/forms.py b/netfields/forms.py
index b2510c3..1114ea5 100644
--- a/netfields/forms.py
+++ b/netfields/forms.py
@@ -2,37 +2,14 @@ from ipaddress import ip_interface, ip_network, _IPAddressBase, _BaseNetwork
 from netaddr import EUI, AddrFormatError
 
 from django import forms
-import django
-from django.forms.utils import flatatt
-from django.utils.safestring import mark_safe
 from django.utils.six import text_type
 from django.core.exceptions import ValidationError
 
 from netfields.mac import mac_unix_common
 
 
-class NetInput(forms.Widget):
-    input_type = 'text'
-
-    def render(self, name, value, attrs=None):
-        # Default forms.Widget compares value != '' which breaks IP...
-        if value is None:
-            value = ''
-        if attrs is None:
-            attrs = {}
-        base_attrs = {
-            "type": self.input_type,
-            "name": name
-        }
-        base_attrs.update(attrs)
-        final_attrs = self.build_attrs(base_attrs)
-        if value:
-            final_attrs['value'] = value
-        return mark_safe(u'<input%s />' % flatatt(final_attrs))
-
-
 class InetAddressFormField(forms.Field):
-    widget = NetInput
+    widget = forms.TextInput
     default_error_messages = {
         'invalid': u'Enter a valid IP address.',
     }
@@ -57,7 +34,7 @@ class InetAddressFormField(forms.Field):
 
 
 class CidrAddressFormField(forms.Field):
-    widget = NetInput
+    widget = forms.TextInput
     default_error_messages = {
         'invalid': u'Enter a valid CIDR address.',
     }
diff --git a/netfields/managers.py b/netfields/managers.py
index 657e9e2..5a65009 100644
--- a/netfields/managers.py
+++ b/netfields/managers.py
@@ -1,11 +1,5 @@
-import datetime
-from ipaddress import _BaseNetwork
-
-from django import VERSION
 from django.db import models
-from django.db.backends.postgresql_psycopg2.base import DatabaseWrapper
-from django.db.models import sql, query
-from django.db.models.fields import DateTimeField
+from ipaddress import _BaseNetwork
 
 try:
     str_type = unicode
@@ -13,73 +7,9 @@ except NameError:
     str_type = str
 
 
-NET_OPERATORS = DatabaseWrapper.operators.copy()
-
-for operator in ['contains', 'startswith', 'endswith']:
-    NET_OPERATORS[operator] = 'ILIKE %s'
-    NET_OPERATORS['i%s' % operator] = 'ILIKE %s'
-
-NET_OPERATORS['iexact'] = NET_OPERATORS['exact']
-NET_OPERATORS['regex'] = NET_OPERATORS['iregex']
-NET_OPERATORS['net_contained'] = '<< %s'
-NET_OPERATORS['net_contained_or_equal'] = '<<= %s'
-NET_OPERATORS['net_contains'] = '>> %s'
-NET_OPERATORS['net_contains_or_equals'] = '>>= %s'
-NET_OPERATORS['net_overlaps'] = '&& %s'
-NET_OPERATORS['max_prefixlen'] = '%s'
-NET_OPERATORS['min_prefixlen'] = '%s'
-
-NET_TEXT_OPERATORS = ['ILIKE %s', '~* %s']
-
-
-class NetQuery(sql.Query):
-    query_terms = sql.Query.query_terms.copy()
-    query_terms.update(NET_OPERATORS)
-
-
-if VERSION < (1, 9):
-    # _prepare_data has been removed / deprecated in
-    # https://github.com/django/django/commit/5008a4db440c8f7d108a6979b959025ffb5789ba
-    class NetWhere(sql.where.WhereNode):
-        def _prepare_data(self, data):
-            """
-            Special form of WhereNode._prepare_data() that does not automatically consume the
-            __iter__ method of _BaseNetwork objects.  This is used in Django >= 1.6
-            """
-            if not isinstance(data, (list, tuple)):
-                return data
-            obj, lookup_type, value = data
-            if not isinstance(value, _BaseNetwork) and hasattr(value, '__iter__') and hasattr(value, 'next'):
-                # Consume any generators immediately, so that we can determine
-                # emptiness and transform any non-empty values correctly.
-                value = list(value)
-
-            # The "value_annotation" parameter is used to pass auxilliary information
-            # about the value(s) to the query construction. Specifically, datetime
-            # and empty values need special handling. Other types could be used
-            # here in the future (using Python types is suggested for consistency).
-            if (isinstance(value, datetime.datetime)
-                or (isinstance(obj.field, DateTimeField) and lookup_type != 'isnull')):
-                value_annotation = datetime.datetime
-            elif hasattr(value, 'value_annotation'):
-                value_annotation = value.value_annotation
-            else:
-                value_annotation = bool(value)
-
-            if hasattr(obj, "prepare"):
-                value = obj.prepare(lookup_type, value)
-            return (obj, lookup_type, value_annotation, value)
-else:
-    NetWhere = sql.where.WhereNode
-
-
 class NetManager(models.Manager):
     use_for_related_fields = True
 
-    def get_queryset(self):
-        q = NetQuery(self.model, NetWhere)
-        return query.QuerySet(self.model, q)
-
     def filter(self, *args, **kwargs):
         for key, val in kwargs.items():
             if isinstance(val, _BaseNetwork):
diff --git a/setup.cfg b/setup.cfg
index 861a9f5..8bfd5a1 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,4 @@
 [egg_info]
 tag_build = 
 tag_date = 0
-tag_svn_revision = 0
 
diff --git a/setup.py b/setup.py
index 70bc3b0..cf9a258 100755
--- a/setup.py
+++ b/setup.py
@@ -12,6 +12,7 @@ def get_long_description():
     with open(path) as f:
         return f.read()
 
+
 requirements = [
     'netaddr',
     'django>=1.8',
@@ -22,7 +23,7 @@ if sys.version_info.major == 2:
 
 setup(
     name='django-netfields',
-    version='0.7.2',
+    version='0.8',
     license='BSD',
     description='Django PostgreSQL netfields implementation',
     long_description=get_long_description(),

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-django-netfields.git



More information about the Python-modules-commits mailing list