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
This commit is contained in:
Adrian Holovaty 2005-12-19 03:51:43 +00:00
parent 2fb5430f3a
commit 50b5f9da63
4 changed files with 10 additions and 9 deletions

View File

@ -2,4 +2,4 @@ class FieldDoesNotExist(Exception):
pass pass
class BadKeywordArguments(Exception): class BadKeywordArguments(Exception):
pass pass

View File

@ -142,7 +142,7 @@ class AutomaticManipulator(Manipulator):
obj_list.sort(lambda x, y: cmp(int(x[0]), int(y[0]))) obj_list.sort(lambda x, y: cmp(int(x[0]), int(y[0])))
# For each related item... # For each related item...
for _, rel_new_data in obj_list: for null, rel_new_data in obj_list:
params = {} params = {}
@ -265,7 +265,7 @@ class ModelChangeManipulator(AutomaticManipulator):
# Let the ObjectDoesNotExist exception propogate up. # Let the ObjectDoesNotExist exception propogate up.
lookup_kwargs = opts.one_to_one_field.rel.limit_choices_to 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 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 = dict([(f.attname, f.get_default()) for f in opts.fields])
params[opts.pk.attname] = obj_key params[opts.pk.attname] = obj_key
original_object = opts.get_model_module().Klass(**params) original_object = opts.get_model_module().Klass(**params)

View File

@ -2,6 +2,7 @@ from django.db import backend, connection
from django.db.models.exceptions import * from django.db.models.exceptions import *
LOOKUP_SEPARATOR = '__' LOOKUP_SEPARATOR = '__'
#################### ####################
# HELPER FUNCTIONS # # HELPER FUNCTIONS #
#################### ####################
@ -119,7 +120,7 @@ class Q:
def get_sql(self, opts, table_count): def get_sql(self, opts, table_count):
return parse_lookup(self.kwargs.items(), opts, table_count) return parse_lookup(self.kwargs.items(), opts, table_count)
def get_where_clause(lookup_type, table_prefix, field_name, value): def get_where_clause(lookup_type, table_prefix, field_name, value):
if table_prefix.endswith('.'): if table_prefix.endswith('.'):
table_prefix = backend.quote_name(table_prefix[:-1])+'.' 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) throw_bad_kwarg_error(kwarg)
except StopIteration: except StopIteration:
continue continue
return tables, join_where, where, params, table_count return tables, join_where, where, params, table_count

View File

@ -56,13 +56,13 @@ class RelatedObject(object):
change = count - len(list) change = count - len(list)
if change > 0: if change > 0:
return list + [None for _ in range(change)] return list + [None for i in range(change)]
if change < 0: if change < 0:
return list[:change] return list[:change]
else: # Just right else: # Just right
return list return list
else: 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): def editable_fields(self):
@ -91,11 +91,11 @@ class RelatedObject(object):
def get_manipulator_fields(self, opts, manipulator, change, follow): def get_manipulator_fields(self, opts, manipulator, change, follow):
# TODO: Remove core fields stuff. # TODO: Remove core fields stuff.
if manipulator.original_object: if manipulator.original_object:
meth_name = 'get_%s_count' % self.get_method_name_part() meth_name = 'get_%s_count' % self.get_method_name_part()
count = getattr(manipulator.original_object, meth_name)() count = getattr(manipulator.original_object, meth_name)()
count += self.field.rel.num_extra_on_change count += self.field.rel.num_extra_on_change
if self.field.rel.min_num_in_admin: if self.field.rel.min_num_in_admin:
count = max(count, self.field.rel.min_num_in_admin) count = max(count, self.field.rel.min_num_in_admin)