mirror of https://github.com/django/django.git
Removed trailing whitespace in a few files.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8571 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
15ed5e61c9
commit
b016ea0ace
|
@ -31,7 +31,7 @@ class GeometryField(SpatialBackend.Field):
|
|||
Indicates whether to create a spatial index. Defaults to True.
|
||||
Set this instead of 'db_index' for geographic fields since index
|
||||
creation is different for geometry columns.
|
||||
|
||||
|
||||
dim:
|
||||
The number of dimensions for this geometry. Defaults to 2.
|
||||
"""
|
||||
|
@ -39,18 +39,18 @@ class GeometryField(SpatialBackend.Field):
|
|||
# Setting the index flag with the value of the `spatial_index` keyword.
|
||||
self._index = spatial_index
|
||||
|
||||
# Setting the SRID and getting the units. Unit information must be
|
||||
# Setting the SRID and getting the units. Unit information must be
|
||||
# easily available in the field instance for distance queries.
|
||||
self._srid = srid
|
||||
self._unit, self._unit_name, self._spheroid = get_srid_info(srid)
|
||||
|
||||
# Setting the dimension of the geometry field.
|
||||
self._dim = dim
|
||||
|
||||
# Setting the verbose_name keyword argument with the positional
|
||||
|
||||
# Setting the verbose_name keyword argument with the positional
|
||||
# first parameter, so this works like normal fields.
|
||||
kwargs['verbose_name'] = verbose_name
|
||||
|
||||
|
||||
super(GeometryField, self).__init__(**kwargs) # Calling the parent initializtion function
|
||||
|
||||
### Routines specific to GeometryField ###
|
||||
|
@ -64,7 +64,7 @@ class GeometryField(SpatialBackend.Field):
|
|||
|
||||
def get_distance(self, dist_val, lookup_type):
|
||||
"""
|
||||
Returns a distance number in units of the field. For example, if
|
||||
Returns a distance number in units of the field. For example, if
|
||||
`D(km=1)` was passed in and the units of the field were in meters,
|
||||
then 1000 would be returned.
|
||||
"""
|
||||
|
@ -84,10 +84,10 @@ class GeometryField(SpatialBackend.Field):
|
|||
else:
|
||||
# Assuming the distance is in the units of the field.
|
||||
dist_param = dist
|
||||
|
||||
|
||||
if SpatialBackend.postgis and self.geodetic and lookup_type != 'dwithin' and option == 'spheroid':
|
||||
# On PostGIS, by default `ST_distance_sphere` is used; but if the
|
||||
# accuracy of `ST_distance_spheroid` is needed than the spheroid
|
||||
# On PostGIS, by default `ST_distance_sphere` is used; but if the
|
||||
# accuracy of `ST_distance_spheroid` is needed than the spheroid
|
||||
# needs to be passed to the SQL stored procedure.
|
||||
return [gqn(self._spheroid), dist_param]
|
||||
else:
|
||||
|
@ -98,7 +98,7 @@ class GeometryField(SpatialBackend.Field):
|
|||
Retrieves the geometry, setting the default SRID from the given
|
||||
lookup parameters.
|
||||
"""
|
||||
if isinstance(value, (tuple, list)):
|
||||
if isinstance(value, (tuple, list)):
|
||||
geom = value[0]
|
||||
else:
|
||||
geom = value
|
||||
|
@ -117,7 +117,7 @@ class GeometryField(SpatialBackend.Field):
|
|||
|
||||
# Assigning the SRID value.
|
||||
geom.srid = self.get_srid(geom)
|
||||
|
||||
|
||||
return geom
|
||||
|
||||
def get_srid(self, geom):
|
||||
|
@ -135,12 +135,12 @@ class GeometryField(SpatialBackend.Field):
|
|||
### Routines overloaded from Field ###
|
||||
def contribute_to_class(self, cls, name):
|
||||
super(GeometryField, self).contribute_to_class(cls, name)
|
||||
|
||||
|
||||
# Setup for lazy-instantiated Geometry object.
|
||||
setattr(cls, self.attname, GeometryProxy(SpatialBackend.Geometry, self))
|
||||
|
||||
def formfield(self, **kwargs):
|
||||
defaults = {'form_class' : forms.GeometryField,
|
||||
defaults = {'form_class' : forms.GeometryField,
|
||||
'geom_type' : self._geom,
|
||||
'null' : self.null,
|
||||
}
|
||||
|
@ -161,8 +161,8 @@ class GeometryField(SpatialBackend.Field):
|
|||
# if it is None.
|
||||
geom = self.get_geometry(value)
|
||||
|
||||
# Getting the WHERE clause list and the associated params list. The params
|
||||
# list is populated with the Adaptor wrapping the Geometry for the
|
||||
# Getting the WHERE clause list and the associated params list. The params
|
||||
# list is populated with the Adaptor wrapping the Geometry for the
|
||||
# backend. The WHERE clause list contains the placeholder for the adaptor
|
||||
# (e.g. any transformation SQL).
|
||||
where = [self.get_placeholder(geom)]
|
||||
|
|
|
@ -44,7 +44,7 @@ def add_lazy_relation(cls, field, relation, operation):
|
|||
If the other model hasn't yet been loaded -- almost a given if you're using
|
||||
lazy relationships -- then the relation won't be set up until the
|
||||
class_prepared signal fires at the end of model initialization.
|
||||
|
||||
|
||||
operation is the work that must be performed once the relation can be resolved.
|
||||
"""
|
||||
# Check for recursive relations
|
||||
|
@ -378,7 +378,7 @@ def create_many_related_manager(superclass, through=False):
|
|||
def get_query_set(self):
|
||||
return superclass.get_query_set(self)._next_is_sticky().filter(**(self.core_filters))
|
||||
|
||||
# If the ManyToMany relation has an intermediary model,
|
||||
# If the ManyToMany relation has an intermediary model,
|
||||
# the add and remove methods do not exist.
|
||||
if through is None:
|
||||
def add(self, *objs):
|
||||
|
@ -773,7 +773,7 @@ class ManyToManyField(RelatedField, Field):
|
|||
limit_choices_to=kwargs.pop('limit_choices_to', None),
|
||||
symmetrical=kwargs.pop('symmetrical', True),
|
||||
through=kwargs.pop('through', None))
|
||||
|
||||
|
||||
self.db_table = kwargs.pop('db_table', None)
|
||||
if kwargs['rel'].through is not None:
|
||||
self.creates_table = False
|
||||
|
@ -817,7 +817,7 @@ class ManyToManyField(RelatedField, Field):
|
|||
self._m2m_column_name_cache = 'from_' + related.model._meta.object_name.lower() + '_id'
|
||||
else:
|
||||
self._m2m_column_name_cache = related.model._meta.object_name.lower() + '_id'
|
||||
|
||||
|
||||
# Return the newly cached value
|
||||
return self._m2m_column_name_cache
|
||||
|
||||
|
@ -831,8 +831,8 @@ class ManyToManyField(RelatedField, Field):
|
|||
for f in self.rel.through_model._meta.fields:
|
||||
if hasattr(f,'rel') and f.rel and f.rel.to == related.parent_model:
|
||||
if related.model == related.parent_model:
|
||||
# If this is an m2m-intermediate to self,
|
||||
# the first foreign key you find will be
|
||||
# If this is an m2m-intermediate to self,
|
||||
# the first foreign key you find will be
|
||||
# the source column. Keep searching for
|
||||
# the second foreign key.
|
||||
if found:
|
||||
|
@ -884,13 +884,13 @@ class ManyToManyField(RelatedField, Field):
|
|||
return new_data
|
||||
|
||||
def contribute_to_class(self, cls, name):
|
||||
super(ManyToManyField, self).contribute_to_class(cls, name)
|
||||
super(ManyToManyField, self).contribute_to_class(cls, name)
|
||||
# Add the descriptor for the m2m relation
|
||||
setattr(cls, self.name, ReverseManyRelatedObjectsDescriptor(self))
|
||||
|
||||
# Set up the accessor for the m2m table name for the relation
|
||||
self.m2m_db_table = curry(self._get_m2m_db_table, cls._meta)
|
||||
|
||||
|
||||
# Populate some necessary rel arguments so that cross-app relations
|
||||
# work correctly.
|
||||
if isinstance(self.rel.through, basestring):
|
||||
|
@ -900,7 +900,7 @@ class ManyToManyField(RelatedField, Field):
|
|||
elif self.rel.through:
|
||||
self.rel.through_model = self.rel.through
|
||||
self.rel.through = self.rel.through._meta.object_name
|
||||
|
||||
|
||||
if isinstance(self.rel.to, basestring):
|
||||
target = self.rel.to
|
||||
else:
|
||||
|
|
|
@ -7,7 +7,7 @@ class Person(models.Model):
|
|||
|
||||
class Meta:
|
||||
ordering = ('name',)
|
||||
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
|
@ -19,7 +19,7 @@ class Group(models.Model):
|
|||
|
||||
class Meta:
|
||||
ordering = ('name',)
|
||||
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
|
@ -31,7 +31,7 @@ class Membership(models.Model):
|
|||
|
||||
class Meta:
|
||||
ordering = ('date_joined', 'invite_reason', 'group')
|
||||
|
||||
|
||||
def __unicode__(self):
|
||||
return "%s is a member of %s" % (self.person.name, self.group.name)
|
||||
|
||||
|
@ -40,10 +40,10 @@ class CustomMembership(models.Model):
|
|||
group = models.ForeignKey(Group)
|
||||
weird_fk = models.ForeignKey(Membership, null=True)
|
||||
date_joined = models.DateTimeField(default=datetime.now)
|
||||
|
||||
|
||||
def __unicode__(self):
|
||||
return "%s is a member of %s" % (self.person.name, self.group.name)
|
||||
|
||||
|
||||
class Meta:
|
||||
db_table = "test_table"
|
||||
|
||||
|
@ -55,7 +55,7 @@ class TestNoDefaultsOrNulls(models.Model):
|
|||
class PersonSelfRefM2M(models.Model):
|
||||
name = models.CharField(max_length=5)
|
||||
friends = models.ManyToManyField('self', through="Friendship", symmetrical=False)
|
||||
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
|
@ -98,7 +98,7 @@ __test__ = {'API_TESTS':"""
|
|||
>>> jim.group_set.all()
|
||||
[<Group: Rock>, <Group: Roll>]
|
||||
|
||||
# Querying the intermediary model works like normal.
|
||||
# Querying the intermediary model works like normal.
|
||||
# In this case we get Jane's membership to Rock.
|
||||
>>> m = Membership.objects.get(person=jane, group=rock)
|
||||
>>> m
|
||||
|
@ -122,7 +122,7 @@ __test__ = {'API_TESTS':"""
|
|||
|
||||
### Forward Descriptors Tests ###
|
||||
|
||||
# Due to complications with adding via an intermediary model,
|
||||
# Due to complications with adding via an intermediary model,
|
||||
# the add method is not provided.
|
||||
>>> rock.members.add(bob)
|
||||
Traceback (most recent call last):
|
||||
|
@ -173,7 +173,7 @@ AttributeError: Cannot set values on a ManyToManyField which specifies an interm
|
|||
|
||||
### Reverse Descriptors Tests ###
|
||||
|
||||
# Due to complications with adding via an intermediary model,
|
||||
# Due to complications with adding via an intermediary model,
|
||||
# the add method is not provided.
|
||||
>>> bob.group_set.add(rock)
|
||||
Traceback (most recent call last):
|
||||
|
@ -287,7 +287,7 @@ AttributeError: Cannot set values on a ManyToManyField which specifies an interm
|
|||
|
||||
### QUERY TESTS ###
|
||||
|
||||
# We can query for the related model by using its attribute name (members, in
|
||||
# We can query for the related model by using its attribute name (members, in
|
||||
# this case).
|
||||
>>> Group.objects.filter(members__name='Bob')
|
||||
[<Group: Roll>]
|
||||
|
@ -315,19 +315,19 @@ AttributeError: Cannot set values on a ManyToManyField which specifies an interm
|
|||
>>> Group.objects.filter(membership__date_joined__gt=datetime(2005, 1, 1), membership__person =jane)
|
||||
[<Group: Rock>]
|
||||
|
||||
# Queries also work in the reverse direction: Now let's see all of the people
|
||||
# Queries also work in the reverse direction: Now let's see all of the people
|
||||
# that have joined Rock since 1 Jan 2005:
|
||||
>>> Person.objects.filter(membership__date_joined__gt=datetime(2005, 1, 1), membership__group=rock)
|
||||
[<Person: Jane>, <Person: Jim>]
|
||||
|
||||
# Conceivably, queries through membership could return correct, but non-unique
|
||||
# querysets. To demonstrate this, we query for all people who have joined a
|
||||
# querysets. To demonstrate this, we query for all people who have joined a
|
||||
# group after 2004:
|
||||
>>> Person.objects.filter(membership__date_joined__gt=datetime(2004, 1, 1))
|
||||
[<Person: Jane>, <Person: Jim>, <Person: Jim>]
|
||||
|
||||
# Jim showed up twice, because he joined two groups ('Rock', and 'Roll'):
|
||||
>>> [(m.person.name, m.group.name) for m in
|
||||
>>> [(m.person.name, m.group.name) for m in
|
||||
... Membership.objects.filter(date_joined__gt=datetime(2004, 1, 1))]
|
||||
[(u'Jane', u'Rock'), (u'Jim', u'Rock'), (u'Jim', u'Roll')]
|
||||
|
||||
|
|
Loading…
Reference in New Issue