mirror of
https://github.com/django/django.git
synced 2025-06-25 21:39:12 +00:00
magic-removal: Fixed negligible indentation errors.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2771 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
a5afa8af63
commit
6ec3a4d9ee
@ -17,11 +17,11 @@ DOT = '.'
|
||||
|
||||
def paginator_number(cl,i):
|
||||
if i == DOT:
|
||||
return '... '
|
||||
return '... '
|
||||
elif i == cl.page_num:
|
||||
return '<span class="this-page">%d</span> ' % (i+1)
|
||||
return '<span class="this-page">%d</span> ' % (i+1)
|
||||
else:
|
||||
return '<a href="%s"%s>%d</a> ' % (cl.get_query_string({PAGE_VAR: i}), (i == cl.paginator.pages-1 and ' class="end"' or ''), i+1)
|
||||
return '<a href="%s"%s>%d</a> ' % (cl.get_query_string({PAGE_VAR: i}), (i == cl.paginator.pages-1 and ' class="end"' or ''), i+1)
|
||||
paginator_number = register.simple_tag(paginator_number)
|
||||
|
||||
def pagination(cl):
|
||||
@ -167,7 +167,7 @@ def items_for_result(cl, result):
|
||||
else:
|
||||
result_repr = escape(str(field_val))
|
||||
if result_repr == '':
|
||||
result_repr = ' '
|
||||
result_repr = ' '
|
||||
if first: # First column is a special case
|
||||
first = False
|
||||
url = cl.url_for_result(result)
|
||||
|
@ -102,7 +102,7 @@ class FieldWrapper(object):
|
||||
return self.field.blank and ' class="optional"' or ''
|
||||
|
||||
def use_raw_id_admin(self):
|
||||
return isinstance(self.field.rel, (models.ManyToOneRel, models.ManyToManyRel)) \
|
||||
return isinstance(self.field.rel, (models.ManyToOneRel, models.ManyToManyRel)) \
|
||||
and self.field.rel.raw_id_admin
|
||||
|
||||
class FormFieldCollectionWrapper(object):
|
||||
@ -183,7 +183,7 @@ auto_populated_field_script = register.simple_tag(auto_populated_field_script)
|
||||
def filter_interface_script_maybe(bound_field):
|
||||
f = bound_field.field
|
||||
if f.rel and isinstance(f.rel, models.ManyToManyRel) and f.rel.filter_interface:
|
||||
return '<script type="text/javascript">addEvent(window, "load", function(e) {' \
|
||||
return '<script type="text/javascript">addEvent(window, "load", function(e) {' \
|
||||
' SelectFilter.init("id_%s", "%s", %s, "%s"); });</script>\n' % (
|
||||
f.name, f.verbose_name, f.rel.filter_interface-1, settings.ADMIN_MEDIA_PREFIX)
|
||||
else:
|
||||
|
@ -32,7 +32,7 @@ class ModPythonRequest(http.HttpRequest):
|
||||
|
||||
def _get_request(self):
|
||||
if not hasattr(self, '_request'):
|
||||
self._request = datastructures.MergeDict(self.POST, self.GET)
|
||||
self._request = datastructures.MergeDict(self.POST, self.GET)
|
||||
return self._request
|
||||
|
||||
def _get_get(self):
|
||||
|
@ -79,7 +79,7 @@ class WSGIRequest(http.HttpRequest):
|
||||
|
||||
def _get_request(self):
|
||||
if not hasattr(self, '_request'):
|
||||
self._request = datastructures.MergeDict(self.POST, self.GET)
|
||||
self._request = datastructures.MergeDict(self.POST, self.GET)
|
||||
return self._request
|
||||
|
||||
def _get_get(self):
|
||||
|
@ -159,15 +159,15 @@ def _get_sql_model_create(klass, models_already_seen=set()):
|
||||
if f.primary_key:
|
||||
field_output.append(style.SQL_KEYWORD('PRIMARY KEY'))
|
||||
if f.rel:
|
||||
if f.rel.to in models_already_seen:
|
||||
field_output.append(style.SQL_KEYWORD('REFERENCES') + ' ' + \
|
||||
style.SQL_TABLE(backend.quote_name(f.rel.to._meta.db_table)) + ' (' + \
|
||||
style.SQL_FIELD(backend.quote_name(f.rel.to._meta.get_field(f.rel.field_name).column)) + ')'
|
||||
)
|
||||
else:
|
||||
# We haven't yet created the table to which this field
|
||||
# is related, so save it for later.
|
||||
pr = pending_references.setdefault(f.rel.to, []).append((klass, f))
|
||||
if f.rel.to in models_already_seen:
|
||||
field_output.append(style.SQL_KEYWORD('REFERENCES') + ' ' + \
|
||||
style.SQL_TABLE(backend.quote_name(f.rel.to._meta.db_table)) + ' (' + \
|
||||
style.SQL_FIELD(backend.quote_name(f.rel.to._meta.get_field(f.rel.field_name).column)) + ')'
|
||||
)
|
||||
else:
|
||||
# We haven't yet created the table to which this field
|
||||
# is related, so save it for later.
|
||||
pr = pending_references.setdefault(f.rel.to, []).append((klass, f))
|
||||
table_output.append(' '.join(field_output))
|
||||
if opts.order_with_respect_to:
|
||||
table_output.append(style.SQL_FIELD(backend.quote_name('_order')) + ' ' + \
|
||||
@ -836,7 +836,7 @@ def get_validation_errors(outfile, app=None):
|
||||
if f.rel:
|
||||
rel_opts = f.rel.to._meta
|
||||
if f.rel.to not in models.get_models():
|
||||
e.add(opts, "'%s' has relation with uninstalled model %s" % (f.name, rel_opts.object_name))
|
||||
e.add(opts, "'%s' has relation with uninstalled model %s" % (f.name, rel_opts.object_name))
|
||||
|
||||
rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name()
|
||||
for r in rel_opts.fields:
|
||||
|
@ -383,7 +383,7 @@ class ServerHandler:
|
||||
assert type(data) is StringType,"write() argument must be string"
|
||||
|
||||
if not self.status:
|
||||
raise AssertionError("write() before start_response()")
|
||||
raise AssertionError("write() before start_response()")
|
||||
|
||||
elif not self.headers_sent:
|
||||
# Before the first output, send the stored headers
|
||||
|
@ -305,9 +305,9 @@ class Field(object):
|
||||
|
||||
def _get_val_from_obj(self, obj):
|
||||
if obj:
|
||||
return getattr(obj, self.attname)
|
||||
return getattr(obj, self.attname)
|
||||
else:
|
||||
return self.get_default()
|
||||
return self.get_default()
|
||||
|
||||
def flatten_data(self, follow, obj=None):
|
||||
"""
|
||||
@ -577,7 +577,7 @@ class FileField(Field):
|
||||
dispatcher.connect(self.delete_file, signal=signals.post_delete, sender=cls)
|
||||
|
||||
def delete_file(self, instance):
|
||||
if getattr(instance, self.attname):
|
||||
if getattr(instance, self.attname):
|
||||
file_name = getattr(instance, 'get_%s_filename' % self.name)()
|
||||
# If the file exists and no other object of this type references it,
|
||||
# delete it from the filesystem.
|
||||
|
@ -539,7 +539,7 @@ class OneToOneField(RelatedField, IntegerField):
|
||||
def contribute_to_related_class(self, cls, related):
|
||||
setattr(cls, related.get_accessor_name(), SingleRelatedObjectDescriptor(related))
|
||||
if not cls._meta.one_to_one_field:
|
||||
cls._meta.one_to_one_field = self
|
||||
cls._meta.one_to_one_field = self
|
||||
|
||||
class ManyToManyField(RelatedField, Field):
|
||||
def __init__(self, to, **kwargs):
|
||||
@ -613,16 +613,16 @@ class ManyToManyField(RelatedField, Field):
|
||||
if obj:
|
||||
instance_ids = [instance._get_pk_val() for instance in getattr(obj, self.name).all()]
|
||||
if self.rel.raw_id_admin:
|
||||
new_data[self.name] = ",".join([str(id) for id in instance_ids])
|
||||
new_data[self.name] = ",".join([str(id) for id in instance_ids])
|
||||
else:
|
||||
new_data[self.name] = instance_ids
|
||||
new_data[self.name] = instance_ids
|
||||
else:
|
||||
# In required many-to-many fields with only one available choice,
|
||||
# select that one available choice.
|
||||
if not self.blank and not self.rel.edit_inline and not self.rel.raw_id_admin:
|
||||
choices_list = self.get_choices_default()
|
||||
if len(choices_list) == 1:
|
||||
new_data[self.name] = [choices_list[0][0]]
|
||||
choices_list = self.get_choices_default()
|
||||
if len(choices_list) == 1:
|
||||
new_data[self.name] = [choices_list[0][0]]
|
||||
return new_data
|
||||
|
||||
def contribute_to_class(self, cls, name):
|
||||
|
@ -239,7 +239,7 @@ class AdminFieldSet(object):
|
||||
self.description = description
|
||||
|
||||
def __repr__(self):
|
||||
return "FieldSet: (%s, %s)" % (self.name, self.field_lines)
|
||||
return "FieldSet: (%s, %s)" % (self.name, self.field_lines)
|
||||
|
||||
def bind(self, field_mapping, original, bound_field_set_class):
|
||||
return bound_field_set_class(self, field_mapping, original)
|
||||
|
@ -52,9 +52,9 @@ class RelatedObject(object):
|
||||
|
||||
count = len(objects) + 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)
|
||||
count = max(count, self.field.rel.min_num_in_admin)
|
||||
if self.field.rel.max_num_in_admin:
|
||||
count = min(count, self.field.rel.max_num_in_admin)
|
||||
count = min(count, self.field.rel.max_num_in_admin)
|
||||
|
||||
change = count - len(objects)
|
||||
if change > 0:
|
||||
|
@ -327,10 +327,10 @@ class FormField:
|
||||
new_data.setlist(name, converted_data)
|
||||
else:
|
||||
try:
|
||||
#individual fields deal with None values themselves
|
||||
new_data.setlist(name, [self.__class__.html2python(None)])
|
||||
#individual fields deal with None values themselves
|
||||
new_data.setlist(name, [self.__class__.html2python(None)])
|
||||
except EmptyValue:
|
||||
new_data.setlist(name, [])
|
||||
new_data.setlist(name, [])
|
||||
|
||||
|
||||
def run_validator(self, new_data, validator):
|
||||
@ -348,7 +348,7 @@ class FormField:
|
||||
try:
|
||||
for validator in self.validator_list:
|
||||
try:
|
||||
self.run_validator(new_data, validator)
|
||||
self.run_validator(new_data, validator)
|
||||
except validators.ValidationError, e:
|
||||
errors.setdefault(self.field_name, []).extend(e.messages)
|
||||
# If a CriticalValidationError is raised, ignore any other ValidationErrors
|
||||
|
@ -198,7 +198,7 @@ class DebugLexer(Lexer):
|
||||
upto = end
|
||||
last_bit = self.template_string[upto:]
|
||||
if last_bit:
|
||||
token_tups.append( (last_bit, (upto, upto + len(last_bit))) )
|
||||
token_tups.append( (last_bit, (upto, upto + len(last_bit))) )
|
||||
return [self.create_token(tok, (self.origin, loc)) for tok, loc in token_tups]
|
||||
|
||||
def create_token(self, token_string, source):
|
||||
@ -245,7 +245,7 @@ class Parser(object):
|
||||
compiled_result = compile_func(self, token)
|
||||
except TemplateSyntaxError, e:
|
||||
if not self.compile_function_error(token, e):
|
||||
raise
|
||||
raise
|
||||
self.extend_nodelist(nodelist, compiled_result, token)
|
||||
self.exit_command()
|
||||
if parse_until:
|
||||
@ -731,7 +731,7 @@ class VariableNode(Node):
|
||||
class DebugVariableNode(VariableNode):
|
||||
def render(self, context):
|
||||
try:
|
||||
output = self.filter_expression.resolve(context)
|
||||
output = self.filter_expression.resolve(context)
|
||||
except TemplateSyntaxError, e:
|
||||
if not hasattr(e, 'source'):
|
||||
e.source = self.source
|
||||
|
@ -86,7 +86,7 @@ class ConstantIncludeNode(Node):
|
||||
self.template = t
|
||||
except:
|
||||
if settings.TEMPLATE_DEBUG:
|
||||
raise
|
||||
raise
|
||||
self.template = None
|
||||
|
||||
def render(self, context):
|
||||
@ -100,16 +100,16 @@ class IncludeNode(Node):
|
||||
self.template_name = template_name
|
||||
|
||||
def render(self, context):
|
||||
try:
|
||||
template_name = resolve_variable(self.template_name, context)
|
||||
t = get_template(template_name)
|
||||
return t.render(context)
|
||||
except TemplateSyntaxError, e:
|
||||
if settings.TEMPLATE_DEBUG:
|
||||
try:
|
||||
template_name = resolve_variable(self.template_name, context)
|
||||
t = get_template(template_name)
|
||||
return t.render(context)
|
||||
except TemplateSyntaxError, e:
|
||||
if settings.TEMPLATE_DEBUG:
|
||||
raise
|
||||
return ''
|
||||
except:
|
||||
return '' # Fail silently for invalid included templates.
|
||||
return ''
|
||||
except:
|
||||
return '' # Fail silently for invalid included templates.
|
||||
|
||||
def do_block(parser, token):
|
||||
"""
|
||||
|
@ -24,14 +24,14 @@ def lazy(func, *resultclasses):
|
||||
# the evaluation and store the result. Afterwards, the result
|
||||
# is delivered directly. So the result is memoized.
|
||||
def __init__(self, args, kw):
|
||||
self.__func = func
|
||||
self.__args = args
|
||||
self.__kw = kw
|
||||
self.__dispatch = {}
|
||||
for resultclass in resultclasses:
|
||||
self.__dispatch[resultclass] = {}
|
||||
for (k, v) in resultclass.__dict__.items():
|
||||
setattr(self, k, self.__promise__(resultclass, k, v))
|
||||
self.__func = func
|
||||
self.__args = args
|
||||
self.__kw = kw
|
||||
self.__dispatch = {}
|
||||
for resultclass in resultclasses:
|
||||
self.__dispatch[resultclass] = {}
|
||||
for (k, v) in resultclass.__dict__.items():
|
||||
setattr(self, k, self.__promise__(resultclass, k, v))
|
||||
|
||||
def __promise__(self, klass, funcname, func):
|
||||
# Builds a wrapper around some magic method and registers that magic
|
||||
|
Loading…
x
Reference in New Issue
Block a user