1
0
mirror of https://github.com/django/django.git synced 2025-06-11 06:29:13 +00:00

magic-removal: Renamed 'object' to 'obj' local variable in date-based and list-detail generic views, so as not to override the Python builtin 'object'

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2405 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-02-27 05:16:24 +00:00
parent fd10c3ae1e
commit 42dec1ef75
2 changed files with 8 additions and 8 deletions

View File

@ -225,18 +225,18 @@ def object_detail(request, year, month, day, queryset, date_field,
else: else:
raise AttributeError, "Generic detail view must be called with either an object_id or a slug/slugfield" raise AttributeError, "Generic detail view must be called with either an object_id or a slug/slugfield"
try: try:
object = queryset.get(**lookup_kwargs) obj = queryset.get(**lookup_kwargs)
except ObjectDoesNotExist: except ObjectDoesNotExist:
raise Http404, "No %s found for" % model._meta.verbose_name raise Http404, "No %s found for" % model._meta.verbose_name
if not template_name: if not template_name:
template_name = "%s/%s_detail" % (model._meta.app_label, model._meta.object_name.lower()) template_name = "%s/%s_detail" % (model._meta.app_label, model._meta.object_name.lower())
if template_name_field: if template_name_field:
template_name_list = [getattr(object, template_name_field), template_name] template_name_list = [getattr(obj, template_name_field), template_name]
t = template_loader.select_template(template_name_list) t = template_loader.select_template(template_name_list)
else: else:
t = template_loader.get_template(template_name) t = template_loader.get_template(template_name)
c = RequestContext(request, { c = RequestContext(request, {
'object': object, 'object': obj,
}, context_processors) }, context_processors)
for key, value in extra_context.items(): for key, value in extra_context.items():
if callable(value): if callable(value):
@ -244,5 +244,5 @@ def object_detail(request, year, month, day, queryset, date_field,
else: else:
c[key] = value c[key] = value
response = HttpResponse(t.render(c)) response = HttpResponse(t.render(c))
populate_xheaders(request, response, model, getattr(object, object._meta.pk.name)) populate_xheaders(request, response, model, getattr(obj, obj._meta.pk.name))
return response return response

View File

@ -95,18 +95,18 @@ def object_detail(request, queryset, object_id=None, slug=None,
else: else:
raise AttributeError, "Generic detail view must be called with either an object_id or a slug/slug_field." raise AttributeError, "Generic detail view must be called with either an object_id or a slug/slug_field."
try: try:
object = queryset.get() obj = queryset.get()
except ObjectDoesNotExist: except ObjectDoesNotExist:
raise Http404, "No %s found matching the query" % (model._meta.verbose_name) raise Http404, "No %s found matching the query" % (model._meta.verbose_name)
if not template_name: if not template_name:
template_name = "%s/%s_detail" % (model._meta.app_label, model._meta.object_name.lower()) template_name = "%s/%s_detail" % (model._meta.app_label, model._meta.object_name.lower())
if template_name_field: if template_name_field:
template_name_list = [getattr(object, template_name_field), template_name] template_name_list = [getattr(obj, template_name_field), template_name]
t = template_loader.select_template(template_name_list) t = template_loader.select_template(template_name_list)
else: else:
t = template_loader.get_template(template_name) t = template_loader.get_template(template_name)
c = RequestContext(request, { c = RequestContext(request, {
'object': object, 'object': obj,
}, context_processors) }, context_processors)
for key, value in extra_context.items(): for key, value in extra_context.items():
if callable(value): if callable(value):
@ -114,5 +114,5 @@ def object_detail(request, queryset, object_id=None, slug=None,
else: else:
c[key] = value c[key] = value
response = HttpResponse(t.render(c)) response = HttpResponse(t.render(c))
populate_xheaders(request, response, model, getattr(object, object._meta.pk.name)) populate_xheaders(request, response, model, getattr(obj, obj._meta.pk.name))
return response return response