From 50b5f9da63e729c55c4a8579b2d57202223b7815 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 19 Dec 2005 03:51:43 +0000 Subject: [PATCH] magic-removal: Got rid of some uses of '_', the special underscore variable, where it's not needed. Trying to solve a weird bug. git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1733 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/exceptions.py | 2 +- django/db/models/manipulators.py | 4 ++-- django/db/models/query.py | 5 +++-- django/db/models/related.py | 8 ++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/django/db/models/exceptions.py b/django/db/models/exceptions.py index e16276f51b..d5a0ccad31 100644 --- a/django/db/models/exceptions.py +++ b/django/db/models/exceptions.py @@ -2,4 +2,4 @@ class FieldDoesNotExist(Exception): pass class BadKeywordArguments(Exception): - pass \ No newline at end of file + pass diff --git a/django/db/models/manipulators.py b/django/db/models/manipulators.py index 46369ea7b5..e94066d2c8 100644 --- a/django/db/models/manipulators.py +++ b/django/db/models/manipulators.py @@ -142,7 +142,7 @@ class AutomaticManipulator(Manipulator): obj_list.sort(lambda x, y: cmp(int(x[0]), int(y[0]))) # For each related item... - for _, rel_new_data in obj_list: + for null, rel_new_data in obj_list: params = {} @@ -265,7 +265,7 @@ class ModelChangeManipulator(AutomaticManipulator): # Let the ObjectDoesNotExist exception propogate up. lookup_kwargs = opts.one_to_one_field.rel.limit_choices_to lookup_kwargs['%s__exact' % opts.one_to_one_field.rel.field_name] = obj_key - _ = opts.one_to_one_field.rel.to._meta.get_model_module().get_object(**lookup_kwargs) + null = opts.one_to_one_field.rel.to._meta.get_model_module().get_object(**lookup_kwargs) params = dict([(f.attname, f.get_default()) for f in opts.fields]) params[opts.pk.attname] = obj_key original_object = opts.get_model_module().Klass(**params) diff --git a/django/db/models/query.py b/django/db/models/query.py index d991285ea2..733cb40450 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -2,6 +2,7 @@ from django.db import backend, connection from django.db.models.exceptions import * LOOKUP_SEPARATOR = '__' + #################### # HELPER FUNCTIONS # #################### @@ -119,7 +120,7 @@ class Q: def get_sql(self, opts, table_count): return parse_lookup(self.kwargs.items(), opts, table_count) - + def get_where_clause(lookup_type, table_prefix, field_name, value): if table_prefix.endswith('.'): table_prefix = backend.quote_name(table_prefix[:-1])+'.' @@ -300,4 +301,4 @@ def parse_lookup(kwarg_items, opts, table_count=0): throw_bad_kwarg_error(kwarg) except StopIteration: continue - return tables, join_where, where, params, table_count \ No newline at end of file + return tables, join_where, where, params, table_count diff --git a/django/db/models/related.py b/django/db/models/related.py index 3f6d6c2dcd..63df71ab0f 100644 --- a/django/db/models/related.py +++ b/django/db/models/related.py @@ -56,13 +56,13 @@ class RelatedObject(object): change = count - len(list) if change > 0: - return list + [None for _ in range(change)] + return list + [None for i in range(change)] if change < 0: return list[:change] else: # Just right return list else: - return [None for _ in range(self.field.rel.num_in_admin)] + return [None for i in range(self.field.rel.num_in_admin)] def editable_fields(self): @@ -91,11 +91,11 @@ class RelatedObject(object): def get_manipulator_fields(self, opts, manipulator, change, follow): # TODO: Remove core fields stuff. - + if manipulator.original_object: meth_name = 'get_%s_count' % self.get_method_name_part() count = getattr(manipulator.original_object, meth_name)() - + count += self.field.rel.num_extra_on_change if self.field.rel.min_num_in_admin: count = max(count, self.field.rel.min_num_in_admin)