Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Continue to attack E302 violations

  • Loading branch information...
commit 19256f300e44b0a682f76fc1dda673862bae49d1 1 parent 8b3d9d9
@alex alex authored
Showing with 171 additions and 2 deletions.
  1. +6 −0 django/contrib/formtools/tests/wizard/namedwizardtests/forms.py
  2. +2 −0  django/contrib/formtools/tests/wizard/namedwizardtests/urls.py
  3. +2 −0  django/contrib/formtools/tests/wizard/test_forms.py
  4. +7 −0 django/contrib/formtools/tests/wizard/wizardtests/forms.py
  5. +1 −0  django/contrib/formtools/wizard/forms.py
  6. +2 −0  django/contrib/formtools/wizard/storage/exceptions.py
  7. +1 −0  django/contrib/formtools/wizard/views.py
  8. +1 −0  django/contrib/gis/admin/options.py
  9. +1 −0  django/contrib/gis/db/backends/base.py
  10. +6 −0 django/contrib/gis/db/backends/mysql/compiler.py
  11. +1 −1  django/contrib/gis/db/backends/mysql/creation.py
  12. +1 −0  django/contrib/gis/db/backends/mysql/introspection.py
  13. +1 −0  django/contrib/gis/db/backends/oracle/adapter.py
  14. +7 −0 django/contrib/gis/db/backends/oracle/compiler.py
  15. +1 −0  django/contrib/gis/db/backends/oracle/creation.py
  16. +1 −0  django/contrib/gis/db/backends/oracle/introspection.py
  17. +2 −0  django/contrib/gis/db/backends/oracle/models.py
  18. +5 −0 django/contrib/gis/db/backends/oracle/operations.py
  19. +1 −0  django/contrib/gis/db/backends/postgis/adapter.py
  20. +2 −0  django/contrib/gis/db/backends/postgis/introspection.py
  21. +2 −0  django/contrib/gis/db/backends/postgis/models.py
  22. +6 −0 django/contrib/gis/db/backends/postgis/operations.py
  23. +1 −0  django/contrib/gis/db/backends/spatialite/adapter.py
  24. +1 −0  django/contrib/gis/db/backends/spatialite/base.py
  25. +1 −0  django/contrib/gis/db/backends/spatialite/client.py
  26. +2 −0  django/contrib/gis/db/backends/spatialite/introspection.py
  27. +2 −0  django/contrib/gis/db/backends/spatialite/models.py
  28. +6 −0 django/contrib/gis/db/backends/spatialite/operations.py
  29. +2 −0  django/contrib/gis/db/backends/utils.py
  30. +5 −0 django/contrib/gis/db/models/aggregates.py
  31. +9 −0 django/contrib/gis/db/models/fields.py
  32. +1 −0  django/contrib/gis/db/models/manager.py
  33. +1 −0  django/contrib/gis/db/models/proxy.py
  34. +2 −0  django/contrib/gis/db/models/query.py
  35. +6 −0 django/contrib/gis/db/models/sql/aggregates.py
  36. +7 −0 django/contrib/gis/db/models/sql/compiler.py
  37. +4 −0 django/contrib/gis/db/models/sql/conversion.py
  38. +1 −0  django/contrib/gis/db/models/sql/query.py
  39. +2 −0  django/contrib/gis/db/models/sql/where.py
  40. +5 −0 django/contrib/gis/feeds.py
  41. +1 −0  django/contrib/gis/gdal/base.py
  42. +1 −0  django/contrib/gis/gdal/datasource.py
  43. +1 −0  django/contrib/gis/gdal/driver.py
  44. +2 −0  django/contrib/gis/gdal/envelope.py
  45. +5 −0 django/contrib/gis/gdal/error.py
  46. +1 −0  django/contrib/gis/gdal/feature.py
  47. +12 −0 django/contrib/gis/gdal/field.py
  48. +1 −1  django/contrib/gis/gdal/geometries.py
  49. +1 −0  django/contrib/gis/gdal/layer.py
  50. +1 −0  django/contrib/gis/gdal/srs.py
  51. +2 −0  django/contrib/gis/geoip/base.py
  52. +1 −0  django/contrib/gis/geos/base.py
  53. +2 −0  django/contrib/gis/geos/io.py
  54. +1 −0  django/contrib/gis/geos/mutable_list.py
  55. +1 −0  django/contrib/gis/geos/polygon.py
  56. +1 −0  django/contrib/gis/geos/prepared.py
  57. +2 −0  django/contrib/gis/measure.py
  58. +4 −0 django/contrib/gis/shortcuts.py
  59. +1 −0  django/contrib/gis/sitemaps/georss.py
  60. +3 −0  django/contrib/gis/sitemaps/kml.py
  61. +1 −0  django/contrib/gis/sitemaps/views.py
  62. +1 −0  django/contrib/gis/tests/test_measure.py
  63. +4 −0 django/contrib/gis/tests/utils.py
  64. +1 −0  django/contrib/gis/views.py
  65. +1 −0  django/contrib/sites/management.py
  66. +1 −0  django/contrib/staticfiles/handlers.py
  67. +1 −0  django/contrib/staticfiles/urls.py
View
6 django/contrib/formtools/tests/wizard/namedwizardtests/forms.py
@@ -14,21 +14,25 @@
temp_storage_location = tempfile.mkdtemp(dir=os.environ.get('DJANGO_TEST_TEMP_DIR'))
temp_storage = FileSystemStorage(location=temp_storage_location)
+
class Page1(forms.Form):
name = forms.CharField(max_length=100)
user = forms.ModelChoiceField(queryset=User.objects.all())
thirsty = forms.NullBooleanField()
+
class Page2(forms.Form):
address1 = forms.CharField(max_length=100)
address2 = forms.CharField(max_length=100)
file1 = forms.FileField()
+
class Page3(forms.Form):
random_crap = forms.CharField(max_length=100)
Page4 = formset_factory(Page3, extra=2)
+
class ContactWizard(NamedUrlWizardView):
file_storage = temp_storage
@@ -44,8 +48,10 @@ def done(self, form_list, **kwargs):
c['this_will_fail'] = self.get_cleaned_data_for_step('this_will_fail')
return HttpResponse(Template('').render(c))
+
class SessionContactWizard(ContactWizard):
storage_name = 'django.contrib.formtools.wizard.storage.session.SessionStorage'
+
class CookieContactWizard(ContactWizard):
storage_name = 'django.contrib.formtools.wizard.storage.cookie.CookieStorage'
View
2  django/contrib/formtools/tests/wizard/namedwizardtests/urls.py
@@ -2,6 +2,7 @@
from django.contrib.formtools.tests.wizard.namedwizardtests.forms import (
SessionContactWizard, CookieContactWizard, Page1, Page2, Page3, Page4)
+
def get_named_session_wizard():
return SessionContactWizard.as_view(
[('form1', Page1), ('form2', Page2), ('form3', Page3), ('form4', Page4)],
@@ -9,6 +10,7 @@ def get_named_session_wizard():
done_step_name='nwiz_session_done'
)
+
def get_named_cookie_wizard():
return CookieContactWizard.as_view(
[('form1', Page1), ('form2', Page2), ('form3', Page3), ('form4', Page4)],
View
2  django/contrib/formtools/tests/wizard/test_forms.py
@@ -81,12 +81,14 @@ def get_form_kwargs(self, step, *args, **kwargs):
kwargs['test'] = True
return kwargs
+
class TestWizardWithInitAttrs(TestWizard):
form_list = [Step1, Step2]
condition_dict = {'step2': True}
initial_dict = {'start': {'name': 'value1'}}
instance_dict = {'start': User()}
+
class FormTests(TestCase):
def test_form_init(self):
testform = TestWizard.get_initkwargs([Step1, Step2])
View
7 django/contrib/formtools/tests/wizard/wizardtests/forms.py
@@ -15,21 +15,25 @@
temp_storage_location = tempfile.mkdtemp(dir=os.environ.get('DJANGO_TEST_TEMP_DIR'))
temp_storage = FileSystemStorage(location=temp_storage_location)
+
class Page1(forms.Form):
name = forms.CharField(max_length=100)
user = forms.ModelChoiceField(queryset=User.objects.all())
thirsty = forms.NullBooleanField()
+
class Page2(forms.Form):
address1 = forms.CharField(max_length=100)
address2 = forms.CharField(max_length=100)
file1 = forms.FileField()
+
class Page3(forms.Form):
random_crap = forms.CharField(max_length=100)
Page4 = formset_factory(Page3, extra=2)
+
class ContactWizard(WizardView):
file_storage = temp_storage
@@ -51,6 +55,7 @@ def get_context_data(self, form, **kwargs):
context.update({'another_var': True})
return context
+
class UserForm(forms.ModelForm):
class Meta:
model = User
@@ -58,8 +63,10 @@ class Meta:
UserFormSet = modelformset_factory(User, form=UserForm)
+
class SessionContactWizard(ContactWizard):
storage_name = 'django.contrib.formtools.wizard.storage.session.SessionStorage'
+
class CookieContactWizard(ContactWizard):
storage_name = 'django.contrib.formtools.wizard.storage.cookie.CookieStorage'
View
1  django/contrib/formtools/wizard/forms.py
@@ -1,5 +1,6 @@
from django import forms
+
class ManagementForm(forms.Form):
"""
``ManagementForm`` is used to keep track of the current wizard step.
View
2  django/contrib/formtools/wizard/storage/exceptions.py
@@ -1,7 +1,9 @@
from django.core.exceptions import ImproperlyConfigured
+
class MissingStorage(ImproperlyConfigured):
pass
+
class NoFileStorageConfigured(ImproperlyConfigured):
pass
View
1  django/contrib/formtools/wizard/views.py
@@ -28,6 +28,7 @@ def normalize_name(name):
new = re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', '_\\1', name)
return new.lower().strip('_')
+
class StepsHelper(object):
def __init__(self, wizard):
View
1  django/contrib/gis/admin/options.py
@@ -3,6 +3,7 @@
from django.contrib.gis.gdal import OGRGeomType
from django.contrib.gis.db import models
+
class GeoModelAdmin(ModelAdmin):
"""
The administration options class for Geographic models. Map settings
View
1  django/contrib/gis/db/backends/base.py
@@ -143,6 +143,7 @@ def geometry_columns(self):
def spatial_ref_sys(self):
raise NotImplementedError('subclasses of BaseSpatialOperations must a provide spatial_ref_sys() method')
+
@python_2_unicode_compatible
class SpatialRefSysMixin(object):
"""
View
6 django/contrib/gis/db/backends/mysql/compiler.py
@@ -3,6 +3,7 @@
SQLCompiler = compiler.SQLCompiler
+
class GeoSQLCompiler(BaseGeoSQLCompiler, SQLCompiler):
def resolve_columns(self, row, fields=()):
"""
@@ -19,17 +20,22 @@ def resolve_columns(self, row, fields=()):
class SQLInsertCompiler(compiler.SQLInsertCompiler, GeoSQLCompiler):
pass
+
class SQLDeleteCompiler(compiler.SQLDeleteCompiler, GeoSQLCompiler):
pass
+
class SQLUpdateCompiler(compiler.SQLUpdateCompiler, GeoSQLCompiler):
pass
+
class SQLAggregateCompiler(compiler.SQLAggregateCompiler, GeoSQLCompiler):
pass
+
class SQLDateCompiler(compiler.SQLDateCompiler, GeoSQLCompiler):
pass
+
class SQLDateTimeCompiler(compiler.SQLDateTimeCompiler, GeoSQLCompiler):
pass
View
2  django/contrib/gis/db/backends/mysql/creation.py
@@ -1,7 +1,7 @@
from django.db.backends.mysql.creation import DatabaseCreation
-class MySQLCreation(DatabaseCreation):
+class MySQLCreation(DatabaseCreation):
def sql_indexes_for_field(self, model, f, style):
from django.contrib.gis.db.models.fields import GeometryField
output = super(MySQLCreation, self).sql_indexes_for_field(model, f, style)
View
1  django/contrib/gis/db/backends/mysql/introspection.py
@@ -3,6 +3,7 @@
from django.contrib.gis.gdal import OGRGeomType
from django.db.backends.mysql.introspection import DatabaseIntrospection
+
class MySQLIntrospection(DatabaseIntrospection):
# Updating the data_types_reverse dictionary with the appropriate
# type for Geometry fields.
View
1  django/contrib/gis/db/backends/oracle/adapter.py
@@ -1,5 +1,6 @@
from cx_Oracle import CLOB
from django.contrib.gis.db.backends.adapter import WKTAdapter
+
class OracleSpatialAdapter(WKTAdapter):
input_size = CLOB
View
7 django/contrib/gis/db/backends/oracle/compiler.py
@@ -3,23 +3,30 @@
SQLCompiler = compiler.SQLCompiler
+
class GeoSQLCompiler(BaseGeoSQLCompiler, SQLCompiler):
pass
+
class SQLInsertCompiler(compiler.SQLInsertCompiler, GeoSQLCompiler):
pass
+
class SQLDeleteCompiler(compiler.SQLDeleteCompiler, GeoSQLCompiler):
pass
+
class SQLUpdateCompiler(compiler.SQLUpdateCompiler, GeoSQLCompiler):
pass
+
class SQLAggregateCompiler(compiler.SQLAggregateCompiler, GeoSQLCompiler):
pass
+
class SQLDateCompiler(compiler.SQLDateCompiler, GeoSQLCompiler):
pass
+
class SQLDateTimeCompiler(compiler.SQLDateTimeCompiler, GeoSQLCompiler):
pass
View
1  django/contrib/gis/db/backends/oracle/creation.py
@@ -1,6 +1,7 @@
from django.db.backends.oracle.creation import DatabaseCreation
from django.db.backends.utils import truncate_name
+
class OracleCreation(DatabaseCreation):
def sql_indexes_for_field(self, model, f, style):
View
1  django/contrib/gis/db/backends/oracle/introspection.py
@@ -3,6 +3,7 @@
from django.db.backends.oracle.introspection import DatabaseIntrospection
from django.utils import six
+
class OracleIntrospection(DatabaseIntrospection):
# Associating any OBJECTVAR instances with GeometryField. Of course,
# this won't work right on Oracle objects that aren't MDSYS.SDO_GEOMETRY,
View
2  django/contrib/gis/db/backends/oracle/models.py
@@ -11,6 +11,7 @@
from django.contrib.gis.db.backends.base import SpatialRefSysMixin
from django.utils.encoding import python_2_unicode_compatible
+
@python_2_unicode_compatible
class GeometryColumns(models.Model):
"Maps to the Oracle USER_SDO_GEOM_METADATA table."
@@ -42,6 +43,7 @@ def geom_col_name(cls):
def __str__(self):
return '%s - %s (SRID: %s)' % (self.table_name, self.column_name, self.srid)
+
class SpatialRefSys(models.Model, SpatialRefSysMixin):
"Maps to the Oracle MDSYS.CS_SRS table."
cs_name = models.CharField(max_length=68)
View
5 django/contrib/gis/db/backends/oracle/operations.py
@@ -28,6 +28,7 @@ def __init__(self, func, **kwargs):
kwargs.setdefault('result', 'TRUE')
super(SDOOperation, self).__init__(func, **kwargs)
+
class SDODistance(SpatialFunction):
"Class for Distance queries."
sql_template = ('%(function)s(%(geo_col)s, %(geometry)s, %(tolerance)s) '
@@ -39,6 +40,7 @@ def __init__(self, op, tolerance=0.05):
tolerance=tolerance,
operator=op, result='%s')
+
class SDODWithin(SpatialFunction):
dwithin_func = 'SDO_WITHIN_DISTANCE'
sql_template = "%(function)s(%(geo_col)s, %(geometry)s, %%s) = 'TRUE'"
@@ -46,6 +48,7 @@ class SDODWithin(SpatialFunction):
def __init__(self):
super(SDODWithin, self).__init__(self.dwithin_func)
+
class SDOGeomRelate(SpatialFunction):
"Class for using SDO_GEOM.RELATE."
relate_func = 'SDO_GEOM.RELATE'
@@ -58,6 +61,7 @@ def __init__(self, mask, tolerance=0.05):
super(SDOGeomRelate, self).__init__(self.relate_func, operator='=',
mask=mask, tolerance=tolerance)
+
class SDORelate(SpatialFunction):
"Class for using SDO_RELATE."
masks = 'TOUCH|OVERLAPBDYDISJOINT|OVERLAPBDYINTERSECT|EQUAL|INSIDE|COVEREDBY|CONTAINS|COVERS|ANYINTERACT|ON'
@@ -73,6 +77,7 @@ def __init__(self, mask):
# Valid distance types and substitutions
dtypes = (Decimal, Distance, float) + six.integer_types
+
class OracleOperations(DatabaseOperations, BaseSpatialOperations):
compiler_module = "django.contrib.gis.db.backends.oracle.compiler"
View
1  django/contrib/gis/db/backends/postgis/adapter.py
@@ -6,6 +6,7 @@
from psycopg2 import Binary
from psycopg2.extensions import ISQLQuote
+
class PostGISAdapter(object):
def __init__(self, geom):
"Initializes on the geometry."
View
2  django/contrib/gis/db/backends/postgis/introspection.py
@@ -1,9 +1,11 @@
from django.db.backends.postgresql_psycopg2.introspection import DatabaseIntrospection
from django.contrib.gis.gdal import OGRGeomType
+
class GeoIntrospectionError(Exception):
pass
+
class PostGISIntrospection(DatabaseIntrospection):
# Reverse dictionary for PostGIS geometry types not populated until
# introspection is actually performed.
View
2  django/contrib/gis/db/backends/postgis/models.py
@@ -5,6 +5,7 @@
from django.contrib.gis.db.backends.base import SpatialRefSysMixin
from django.utils.encoding import python_2_unicode_compatible
+
@python_2_unicode_compatible
class GeometryColumns(models.Model):
"""
@@ -44,6 +45,7 @@ def __str__(self):
(self.f_table_name, self.f_geometry_column,
self.coord_dimension, self.type, self.srid)
+
class SpatialRefSys(models.Model, SpatialRefSysMixin):
"""
The 'spatial_ref_sys' table from PostGIS. See the PostGIS
View
6 django/contrib/gis/db/backends/postgis/operations.py
@@ -22,15 +22,18 @@ class PostGISOperator(SpatialOperation):
def __init__(self, operator):
super(PostGISOperator, self).__init__(operator=operator)
+
class PostGISFunction(SpatialFunction):
"For PostGIS function calls (e.g., `ST_Contains(table, geom)`)."
def __init__(self, prefix, function, **kwargs):
super(PostGISFunction, self).__init__(prefix + function, **kwargs)
+
class PostGISFunctionParam(PostGISFunction):
"For PostGIS functions that take another parameter (e.g. DWithin, Relate)."
sql_template = '%(function)s(%(geo_col)s, %(geometry)s, %%s)'
+
class PostGISDistance(PostGISFunction):
"For PostGIS distance operations."
dist_func = 'Distance'
@@ -40,6 +43,7 @@ def __init__(self, prefix, operator):
super(PostGISDistance, self).__init__(prefix, self.dist_func,
operator=operator)
+
class PostGISSpheroidDistance(PostGISFunction):
"For PostGIS spherical distance operations (using the spheroid)."
dist_func = 'distance_spheroid'
@@ -50,10 +54,12 @@ def __init__(self, prefix, operator):
super(PostGISSpheroidDistance, self).__init__(prefix, self.dist_func,
operator=operator)
+
class PostGISSphereDistance(PostGISDistance):
"For PostGIS spherical distance operations."
dist_func = 'distance_sphere'
+
class PostGISRelate(PostGISFunctionParam):
"For PostGIS Relate(<geom>, <pattern>) calls."
pattern_regex = re.compile(r'^[012TF\*]{9}$')
View
1  django/contrib/gis/db/backends/spatialite/adapter.py
@@ -1,6 +1,7 @@
from django.db.backends.sqlite3.base import Database
from django.contrib.gis.db.backends.adapter import WKTAdapter
+
class SpatiaLiteAdapter(WKTAdapter):
"SQLite adaptor for geometry objects."
def __conform__(self, protocol):
View
1  django/contrib/gis/db/backends/spatialite/base.py
@@ -11,6 +11,7 @@
from django.contrib.gis.db.backends.spatialite.operations import SpatiaLiteOperations
from django.utils import six
+
class DatabaseWrapper(SQLiteDatabaseWrapper):
def __init__(self, *args, **kwargs):
# Before we get too far, make sure pysqlite 2.5+ is installed.
View
1  django/contrib/gis/db/backends/spatialite/client.py
@@ -1,4 +1,5 @@
from django.db.backends.sqlite3.client import DatabaseClient
+
class SpatiaLiteClient(DatabaseClient):
executable_name = 'spatialite'
View
2  django/contrib/gis/db/backends/spatialite/introspection.py
@@ -2,6 +2,7 @@
from django.db.backends.sqlite3.introspection import DatabaseIntrospection, FlexibleFieldLookupDict
from django.utils import six
+
class GeoFlexibleFieldLookupDict(FlexibleFieldLookupDict):
"""
Sublcass that includes updates the `base_data_types_reverse` dict
@@ -18,6 +19,7 @@ class GeoFlexibleFieldLookupDict(FlexibleFieldLookupDict):
'geometrycollection': 'GeometryField',
})
+
class SpatiaLiteIntrospection(DatabaseIntrospection):
data_types_reverse = GeoFlexibleFieldLookupDict()
View
2  django/contrib/gis/db/backends/spatialite/models.py
@@ -5,6 +5,7 @@
from django.contrib.gis.db.backends.base import SpatialRefSysMixin
from django.utils.encoding import python_2_unicode_compatible
+
@python_2_unicode_compatible
class GeometryColumns(models.Model):
"""
@@ -42,6 +43,7 @@ def __str__(self):
(self.f_table_name, self.f_geometry_column,
self.coord_dimension, self.type, self.srid)
+
class SpatialRefSys(models.Model, SpatialRefSysMixin):
"""
The 'spatial_ref_sys' table from SpatiaLite.
View
6 django/contrib/gis/db/backends/spatialite/operations.py
@@ -19,15 +19,18 @@ class SpatiaLiteOperator(SpatialOperation):
def __init__(self, operator):
super(SpatiaLiteOperator, self).__init__(operator=operator)
+
class SpatiaLiteFunction(SpatialFunction):
"For SpatiaLite function calls."
def __init__(self, function, **kwargs):
super(SpatiaLiteFunction, self).__init__(function, **kwargs)
+
class SpatiaLiteFunctionParam(SpatiaLiteFunction):
"For SpatiaLite functions that take another parameter."
sql_template = '%(function)s(%(geo_col)s, %(geometry)s, %%s)'
+
class SpatiaLiteDistance(SpatiaLiteFunction):
"For SpatiaLite distance operations."
dist_func = 'Distance'
@@ -37,6 +40,7 @@ def __init__(self, operator):
super(SpatiaLiteDistance, self).__init__(self.dist_func,
operator=operator)
+
class SpatiaLiteRelate(SpatiaLiteFunctionParam):
"For SpatiaLite Relate(<geom>, <pattern>) calls."
pattern_regex = re.compile(r'^[012TF\*]{9}$')
@@ -46,12 +50,14 @@ def __init__(self, pattern):
raise ValueError('Invalid intersection matrix pattern "%s".' % pattern)
super(SpatiaLiteRelate, self).__init__('Relate')
+
# Valid distance types and substitutions
dtypes = (Decimal, Distance, float) + six.integer_types
def get_dist_ops(operator):
"Returns operations for regular distances; spherical distances are not currently supported."
return (SpatiaLiteDistance(operator),)
+
class SpatiaLiteOperations(DatabaseOperations, BaseSpatialOperations):
compiler_module = 'django.contrib.gis.db.models.sql.compiler'
name = 'spatialite'
View
2  django/contrib/gis/db/backends/utils.py
@@ -3,6 +3,7 @@
backends.
"""
+
class SpatialOperation(object):
"""
Base class for generating spatial SQL.
@@ -28,6 +29,7 @@ def params(self, geo_col, geometry):
params.update(self.extra)
return params
+
class SpatialFunction(SpatialOperation):
"""
Base class for generating spatial SQL related to a function.
View
5 django/contrib/gis/db/models/aggregates.py
@@ -1,16 +1,21 @@
from django.db.models import Aggregate
+
class Collect(Aggregate):
name = 'Collect'
+
class Extent(Aggregate):
name = 'Extent'
+
class Extent3D(Aggregate):
name = 'Extent3D'
+
class MakeLine(Aggregate):
name = 'MakeLine'
+
class Union(Aggregate):
name = 'Union'
View
9 django/contrib/gis/db/models/fields.py
@@ -11,6 +11,7 @@
# for SRID info each time a distance query is constructed.
_srid_cache = {}
+
def get_srid_info(srid, connection):
"""
Returns the units, unit name, and spheroid WKT associated with the
@@ -39,6 +40,7 @@ def get_srid_info(srid, connection):
return _srid_cache[connection.alias][srid]
+
class GeometryField(Field):
"The base GIS field -- maps to the OpenGIS Specification Geometry type."
@@ -269,37 +271,44 @@ def get_placeholder(self, value, connection):
"""
return connection.ops.get_geom_placeholder(self, value)
+
# The OpenGIS Geometry Type Fields
class PointField(GeometryField):
geom_type = 'POINT'
form_class = forms.PointField
description = _("Point")
+
class LineStringField(GeometryField):
geom_type = 'LINESTRING'
form_class = forms.LineStringField
description = _("Line string")
+
class PolygonField(GeometryField):
geom_type = 'POLYGON'
form_class = forms.PolygonField
description = _("Polygon")
+
class MultiPointField(GeometryField):
geom_type = 'MULTIPOINT'
form_class = forms.MultiPointField
description = _("Multi-point")
+
class MultiLineStringField(GeometryField):
geom_type = 'MULTILINESTRING'
form_class = forms.MultiLineStringField
description = _("Multi-line string")
+
class MultiPolygonField(GeometryField):
geom_type = 'MULTIPOLYGON'
form_class = forms.MultiPolygonField
description = _("Multi polygon")
+
class GeometryCollectionField(GeometryField):
geom_type = 'GEOMETRYCOLLECTION'
form_class = forms.GeometryCollectionField
View
1  django/contrib/gis/db/models/manager.py
@@ -1,6 +1,7 @@
from django.db.models.manager import Manager
from django.contrib.gis.db.models.query import GeoQuerySet
+
class GeoManager(Manager):
"Overrides Manager to return Geographic QuerySets."
View
1  django/contrib/gis/db/models/proxy.py
@@ -8,6 +8,7 @@
from django.contrib.gis import memoryview
from django.utils import six
+
class GeometryProxy(object):
def __init__(self, klass, field):
"""
View
2  django/contrib/gis/db/models/query.py
@@ -782,6 +782,7 @@ def _geocol_select(self, geo_field, field_name):
else:
return self.query.get_compiler(self.db)._field_column(geo_field)
+
class GeoValuesQuerySet(ValuesQuerySet):
def __init__(self, *args, **kwargs):
super(GeoValuesQuerySet, self).__init__(*args, **kwargs)
@@ -790,5 +791,6 @@ def __init__(self, *args, **kwargs):
# of string values are returned with `values()` or `values_list()`.
self.query.geo_values = True
+
class GeoValuesListQuerySet(GeoValuesQuerySet, ValuesListQuerySet):
pass
View
6 django/contrib/gis/db/models/sql/aggregates.py
@@ -1,6 +1,7 @@
from django.db.models.sql.aggregates import *
from django.contrib.gis.db.models.fields import GeometryField
+
class GeoAggregate(Aggregate):
# Default SQL template for spatial aggregates.
sql_template = '%(function)s(%(field)s)'
@@ -46,17 +47,22 @@ def as_sql(self, qn, connection):
return sql_template % substitutions, params
+
class Collect(GeoAggregate):
pass
+
class Extent(GeoAggregate):
is_extent = '2D'
+
class Extent3D(GeoAggregate):
is_extent = '3D'
+
class MakeLine(GeoAggregate):
pass
+
class Union(GeoAggregate):
pass
View
7 django/contrib/gis/db/models/sql/compiler.py
@@ -10,6 +10,7 @@
SQLCompiler = compiler.SQLCompiler
+
class GeoSQLCompiler(compiler.SQLCompiler):
def get_columns(self, with_aliases=False):
@@ -249,18 +250,23 @@ def _field_column(self, field, table_alias=None, column=None):
return "%s.%s" % (self.quote_name_unless_alias(table_alias),
self.connection.ops.quote_name(column or field.column))
+
class SQLInsertCompiler(compiler.SQLInsertCompiler, GeoSQLCompiler):
pass
+
class SQLDeleteCompiler(compiler.SQLDeleteCompiler, GeoSQLCompiler):
pass
+
class SQLUpdateCompiler(compiler.SQLUpdateCompiler, GeoSQLCompiler):
pass
+
class SQLAggregateCompiler(compiler.SQLAggregateCompiler, GeoSQLCompiler):
pass
+
class SQLDateCompiler(compiler.SQLDateCompiler, GeoSQLCompiler):
"""
This is overridden for GeoDjango to properly cast date columns, since
@@ -286,6 +292,7 @@ def results_iter(self):
date = date.date()
yield date
+
class SQLDateTimeCompiler(compiler.SQLDateTimeCompiler, GeoSQLCompiler):
"""
This is overridden for GeoDjango to properly cast date columns, since
View
4 django/contrib/gis/db/models/sql/conversion.py
@@ -3,6 +3,7 @@
to convert geospatial values from the database.
"""
+
class BaseField(object):
empty_strings_allowed = True
@@ -10,16 +11,19 @@ def get_internal_type(self):
"Overloaded method so OracleQuery.convert_values doesn't balk."
return None
+
class AreaField(BaseField):
"Wrapper for Area values."
def __init__(self, area_att):
self.area_att = area_att
+
class DistanceField(BaseField):
"Wrapper for Distance values."
def __init__(self, distance_att):
self.distance_att = distance_att
+
class GeomField(BaseField):
"""
Wrapper for Geometry values. It is a lightweight alternative to
View
1  django/contrib/gis/db/models/sql/query.py
@@ -21,6 +21,7 @@
])
ALL_TERMS.update(sql.constants.QUERY_TERMS)
+
class GeoQuery(sql.Query):
"""
A single spatial SQL query.
View
2  django/contrib/gis/db/models/sql/where.py
@@ -4,6 +4,7 @@
from django.db.models.sql.where import Constraint, WhereNode
from django.contrib.gis.db.models.fields import GeometryField
+
class GeoConstraint(Constraint):
"""
This subclass overrides `process` to better handle geographic SQL
@@ -27,6 +28,7 @@ def process(self, lookup_type, value, connection):
params = self.field.get_db_prep_lookup(lookup_type, value, connection=connection)
return (self.alias, self.col, db_type), params
+
class GeoWhereNode(WhereNode):
"""
Used to represent the SQL where-clause for spatial databases --
View
5 django/contrib/gis/feeds.py
@@ -3,6 +3,7 @@
from django.contrib.syndication.views import Feed as BaseFeed
from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed
+
class GeoFeedMixin(object):
"""
This mixin provides the necessary routines for SyndicationFeed subclasses
@@ -79,6 +80,7 @@ def add_georss_element(self, handler, item, w3c_geo=False):
else:
raise ValueError('Geometry type "%s" not supported.' % geom.geom_type)
+
### SyndicationFeed subclasses ###
class GeoRSSFeed(Rss201rev2Feed, GeoFeedMixin):
def rss_attributes(self):
@@ -94,6 +96,7 @@ def add_root_elements(self, handler):
super(GeoRSSFeed, self).add_root_elements(handler)
self.add_georss_element(handler, self.feed)
+
class GeoAtom1Feed(Atom1Feed, GeoFeedMixin):
def root_attributes(self):
attrs = super(GeoAtom1Feed, self).root_attributes()
@@ -108,6 +111,7 @@ def add_root_elements(self, handler):
super(GeoAtom1Feed, self).add_root_elements(handler)
self.add_georss_element(handler, self.feed)
+
class W3CGeoFeed(Rss201rev2Feed, GeoFeedMixin):
def rss_attributes(self):
attrs = super(W3CGeoFeed, self).rss_attributes()
@@ -122,6 +126,7 @@ def add_root_elements(self, handler):
super(W3CGeoFeed, self).add_root_elements(handler)
self.add_georss_element(handler, self.feed, w3c_geo=True)
+
### Feed subclass ###
class Feed(BaseFeed):
"""
View
1  django/contrib/gis/gdal/base.py
@@ -3,6 +3,7 @@
from django.contrib.gis.gdal.error import GDALException
from django.utils import six
+
class GDALBase(object):
"""
Base object for GDAL objects that has a pointer access property
View
1  django/contrib/gis/gdal/datasource.py
@@ -49,6 +49,7 @@
from django.utils import six
from django.utils.six.moves import xrange
+
# For more information, see the OGR C API source code:
# http://www.gdal.org/ogr/ogr__api_8h.html
#
View
1  django/contrib/gis/gdal/driver.py
@@ -7,6 +7,7 @@
from django.utils import six
from django.utils.encoding import force_bytes
+
# For more information, see the OGR C API source code:
# http://www.gdal.org/ogr/ogr__api_8h.html
#
View
2  django/contrib/gis/gdal/envelope.py
@@ -13,6 +13,7 @@
from ctypes import Structure, c_double
from django.contrib.gis.gdal.error import OGRException
+
# The OGR definition of an Envelope is a C structure containing four doubles.
# See the 'ogr_core.h' source file for more information:
# http://www.gdal.org/ogr/ogr__core_8h-source.html
@@ -24,6 +25,7 @@ class OGREnvelope(Structure):
("MaxY", c_double),
]
+
class Envelope(object):
"""
The Envelope object is a C structure that contains the minimum and
View
5 django/contrib/gis/gdal/error.py
@@ -3,16 +3,20 @@
check_err() routine which checks the status code returned by
OGR methods.
"""
+
#### OGR & SRS Exceptions ####
class GDALException(Exception):
pass
+
class OGRException(Exception):
pass
+
class SRSException(Exception):
pass
+
class OGRIndexError(OGRException, KeyError):
"""
This exception is raised when an invalid index is encountered, and has
@@ -37,6 +41,7 @@ class OGRIndexError(OGRException, KeyError):
}
OGRERR_NONE = 0
+
def check_err(code):
"Checks the given OGRERR, and raises an exception where appropriate."
View
1  django/contrib/gis/gdal/feature.py
@@ -11,6 +11,7 @@
from django.utils import six
from django.utils.six.moves import xrange
+
# For more information, see the OGR C API source code:
# http://www.gdal.org/ogr/ogr__api_8h.html
#
View
12 django/contrib/gis/gdal/field.py
@@ -102,6 +102,7 @@ def width(self):
"Returns the width of this Field."
return capi.get_field_width(self.ptr)
+
### The Field sub-classes for each OGR Field type. ###
class OFTInteger(Field):
_double = False
@@ -125,22 +126,27 @@ def type(self):
"""
return 0
+
class OFTReal(Field):
@property
def value(self):
"Returns a float contained in this field."
return self.as_double()
+
# String & Binary fields, just subclasses
class OFTString(Field):
pass
+
class OFTWideString(Field):
pass
+
class OFTBinary(Field):
pass
+
# OFTDate, OFTTime, OFTDateTime fields.
class OFTDate(Field):
@property
@@ -152,6 +158,7 @@ def value(self):
except (ValueError, OGRException):
return None
+
class OFTDateTime(Field):
@property
def value(self):
@@ -166,6 +173,7 @@ def value(self):
except (ValueError, OGRException):
return None
+
class OFTTime(Field):
@property
def value(self):
@@ -176,16 +184,20 @@ def value(self):
except (ValueError, OGRException):
return None
+
# List fields are also just subclasses
class OFTIntegerList(Field):
pass
+
class OFTRealList(Field):
pass
+
class OFTStringList(Field):
pass
+
class OFTWideStringList(Field):
pass
View
2  django/contrib/gis/gdal/geometries.py
@@ -67,7 +67,7 @@
#
# The OGR_G_* routines are relevant here.
-#### OGRGeometry Class ####
+
class OGRGeometry(GDALBase):
"Generally encapsulates an OGR geometry."
View
1  django/contrib/gis/gdal/layer.py
@@ -18,6 +18,7 @@
from django.utils import six
from django.utils.six.moves import xrange
+
# For more information, see the OGR C API source code:
# http://www.gdal.org/ogr/ogr__api_8h.html
#
View
1  django/contrib/gis/gdal/srs.py
@@ -328,6 +328,7 @@ def xml(self, dialect=''):
"Returns the XML representation of this Spatial Reference."
return capi.to_xml(self.ptr, byref(c_char_p()), dialect)
+
class CoordTransform(GDALBase):
"The coordinate system transformation object."
View
2  django/contrib/gis/geoip/base.py
@@ -17,10 +17,12 @@
free_regex = re.compile(r'^GEO-\d{3}FREE')
lite_regex = re.compile(r'^GEO-\d{3}LITE')
+
#### GeoIP classes ####
class GeoIPException(Exception):
pass
+
class GeoIP(object):
# The flags for GeoIP memory caching.
# GEOIP_STANDARD - read database from filesystem, uses least memory.
View
1  django/contrib/gis/geos/base.py
@@ -18,6 +18,7 @@ class GDALInfo(object):
except ImportError:
numpy = False
+
class GEOSBase(object):
"""
Base object for GEOS objects that has a pointer access property
View
2  django/contrib/gis/geos/io.py
@@ -6,12 +6,14 @@
from django.contrib.gis.geos.geometry import GEOSGeometry
from django.contrib.gis.geos.prototypes.io import _WKTReader, _WKBReader, WKBWriter, WKTWriter
+
# Public classes for (WKB|WKT)Reader, which return GEOSGeometry
class WKBReader(_WKBReader):
def read(self, wkb):
"Returns a GEOSGeometry for the given WKB buffer."
return GEOSGeometry(super(WKBReader, self).read(wkb))
+
class WKTReader(_WKTReader):
def read(self, wkt):
"Returns a GEOSGeometry for the given WKT string."
View
1  django/contrib/gis/geos/mutable_list.py
@@ -12,6 +12,7 @@
from django.utils import six
from django.utils.six.moves import xrange
+
@total_ordering
class ListMixin(object):
"""
View
1  django/contrib/gis/geos/polygon.py
@@ -6,6 +6,7 @@
from django.utils import six
from django.utils.six.moves import xrange
+
class Polygon(GEOSGeometry):
_minlength = 1
View
1  django/contrib/gis/geos/prepared.py
@@ -2,6 +2,7 @@
from django.contrib.gis.geos.geometry import GEOSGeometry
from django.contrib.gis.geos.prototypes import prepared as capi
+
class PreparedGeometry(GEOSBase):
"""
A geometry that is prepared for performing certain operations.
View
2  django/contrib/gis/measure.py
@@ -44,6 +44,7 @@
NUMERIC_TYPES = six.integer_types + (float, Decimal)
AREA_PREFIX = "sq_"
+
def pretty_name(obj):
return obj.__name__ if obj.__class__ == type else obj.__class__.__name__
@@ -218,6 +219,7 @@ def unit_attname(cls, unit_str):
else:
raise Exception('Could not find a unit keyword associated with "%s"' % unit_str)
+
class Distance(MeasureBase):
STANDARD_UNIT = "m"
UNITS = {
View
4 django/contrib/gis/shortcuts.py
@@ -5,6 +5,7 @@
from django.http import HttpResponse
from django.template import loader
+
def compress_kml(kml):
"Returns compressed KMZ from the given KML string."
kmz = BytesIO()
@@ -14,11 +15,13 @@ def compress_kml(kml):
kmz.seek(0)
return kmz.read()
+
def render_to_kml(*args, **kwargs):
"Renders the response as KML (using the correct MIME type)."
return HttpResponse(loader.render_to_string(*args, **kwargs),
content_type='application/vnd.google-earth.kml+xml')
+
def render_to_kmz(*args, **kwargs):
"""
Compresses the KML content and returns as KMZ (using the correct
@@ -27,6 +30,7 @@ def render_to_kmz(*args, **kwargs):
return HttpResponse(compress_kml(loader.render_to_string(*args, **kwargs)),
content_type='application/vnd.google-earth.kmz')
+
def render_to_text(*args, **kwargs):
"Renders the response using the MIME type for plain text."
return HttpResponse(loader.render_to_string(*args, **kwargs),
View
1  django/contrib/gis/sitemaps/georss.py
@@ -1,6 +1,7 @@
from django.core import urlresolvers
from django.contrib.sitemaps import Sitemap
+
class GeoRSSSitemap(Sitemap):
"""
A minimal hook to produce sitemaps for GeoRSS feeds.
View
3  django/contrib/gis/sitemaps/kml.py
@@ -3,6 +3,7 @@
from django.contrib.gis.db.models.fields import GeometryField
from django.db import models
+
class KMLSitemap(Sitemap):
"""
A minimal hook to produce KML sitemaps.
@@ -60,5 +61,7 @@ def location(self, obj):
'field_name': obj[2],
}
)
+
+
class KMZSitemap(KMLSitemap):
geo_format = 'kmz'
View
1  django/contrib/gis/sitemaps/views.py
@@ -14,6 +14,7 @@
from django.contrib.gis.shortcuts import render_to_kml, render_to_kmz
+
def index(request, sitemaps):
"""
This view generates a sitemap index that uses the proper view
View
1  django/contrib/gis/tests/test_measure.py
@@ -144,6 +144,7 @@ def testUnitAttName(self):
for nm, att in unit_tuple:
self.assertEqual(att, D.unit_attname(nm))
+
class AreaTest(unittest.TestCase):
"Testing the Area object"
View
4 django/contrib/gis/tests/utils.py
@@ -14,17 +14,21 @@ def inner():
else:
return test_func
+
# Decorators to disable entire test functions for specific
# spatial backends.
def no_oracle(func):
return no_backend(func, 'oracle')
+
def no_postgis(func):
return no_backend(func, 'postgis')
+
def no_mysql(func):
return no_backend(func, 'mysql')
+
def no_spatialite(func):
return no_backend(func, 'spatialite')
View
1  django/contrib/gis/views.py
@@ -3,6 +3,7 @@
from django.http import Http404
from django.utils.translation import ugettext as _
+
def feed(request, url, feed_dict=None):
"""Provided for backwards compatibility."""
if not feed_dict:
View
1  django/contrib/sites/management.py
@@ -9,6 +9,7 @@
from django.contrib.sites import models as site_app
from django.core.management.color import no_style
+
def create_default_site(app, created_models, verbosity, db, **kwargs):
# Only create the default sites in databases where Django created the table
if Site in created_models and router.allow_migrate(db, Site):
View
1  django/contrib/staticfiles/handlers.py
@@ -6,6 +6,7 @@
from django.contrib.staticfiles import utils
from django.contrib.staticfiles.views import serve
+
class StaticFilesHandler(WSGIHandler):
"""
WSGI middleware that intercepts calls to the static files directory, as
View
1  django/contrib/staticfiles/urls.py
@@ -3,6 +3,7 @@
urlpatterns = []
+
def staticfiles_urlpatterns(prefix=None):
"""
Helper function to return a URL pattern for serving static files.
Please sign in to comment.
Something went wrong with that request. Please try again.