Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #13827 -- Cleaned up a few unnecessary function calls.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13876 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 1df1378f9e6e71588f45624c4ddf9e5d37cc875a 1 parent d8d38ec
@jezdez jezdez authored
View
2  django/conf/__init__.py
@@ -102,7 +102,7 @@ def __init__(self, settings_module):
new_installed_apps.append(app)
self.INSTALLED_APPS = new_installed_apps
- if hasattr(time, 'tzset') and getattr(self, 'TIME_ZONE'):
+ if hasattr(time, 'tzset') and self.TIME_ZONE:
# When we can, attempt to validate the timezone. If we can't find
# this file, no check happens and it's harmless.
zoneinfo_root = '/usr/share/zoneinfo'
View
2  django/contrib/admin/validation.py
@@ -170,7 +170,7 @@ def validate_inline(cls, parent, parent_model):
fk = _get_foreign_key(parent_model, cls.model, fk_name=cls.fk_name, can_fail=True)
# extra = 3
- if not isinstance(getattr(cls, 'extra'), int):
+ if not isinstance(cls.extra, int):
raise ImproperlyConfigured("'%s.extra' should be a integer."
% cls.__name__)
View
9 django/contrib/auth/__init__.py
@@ -20,15 +20,12 @@ def load_backend(path):
cls = getattr(mod, attr)
except AttributeError:
raise ImproperlyConfigured('Module "%s" does not define a "%s" authentication backend' % (module, attr))
- try:
- getattr(cls, 'supports_object_permissions')
- except AttributeError:
+ if not hasattr(cls, "supports_object_permissions"):
warn("Authentication backends without a `supports_object_permissions` attribute are deprecated. Please define it in %s." % cls,
PendingDeprecationWarning)
cls.supports_object_permissions = False
- try:
- getattr(cls, 'supports_anonymous_user')
- except AttributeError:
+
+ if not hasattr(cls, 'supports_anonymous_user'):
warn("Authentication backends without a `supports_anonymous_user` attribute are deprecated. Please define it in %s." % cls,
PendingDeprecationWarning)
cls.supports_anonymous_user = False
View
2  django/contrib/gis/sitemaps/views.py
@@ -93,7 +93,7 @@ def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB
else:
qs = klass._default_manager.using(using).all()
for mod in qs:
- setattr(mod, 'kml', getattr(mod, field_name).kml)
+ mod.kml = getattr(mod, field_name).kml)
placemarks.append(mod)
# Getting the render function and rendering to the correct.
View
2  django/core/cache/__init__.py
@@ -63,7 +63,7 @@ def get_cache(backend_uri):
else:
name = scheme
module = importlib.import_module(name)
- return getattr(module, 'CacheClass')(host, params)
+ return module.CacheClass(host, params)
cache = get_cache(settings.CACHE_BACKEND)
View
2  django/db/models/base.py
@@ -508,7 +508,7 @@ def save_base(self, raw=False, cls=None, origin=None, force_insert=False,
# autopopulate the _order field
field = meta.order_with_respect_to
order_value = manager.using(using).filter(**{field.name: getattr(self, field.attname)}).count()
- setattr(self, '_order', order_value)
+ self._order = order_value
if not pk_set:
if force_update:
View
6 django/db/models/options.py
@@ -79,14 +79,14 @@ def contribute_to_class(self, cls, name):
# unique_together can be either a tuple of tuples, or a single
# tuple of two strings. Normalize it to a tuple of tuples, so that
# calling code can uniformly expect that.
- ut = meta_attrs.pop('unique_together', getattr(self, 'unique_together'))
+ ut = meta_attrs.pop('unique_together', self.unique_together)
if ut and not isinstance(ut[0], (tuple, list)):
ut = (ut,)
- setattr(self, 'unique_together', ut)
+ self.unique_together = ut
# verbose_name_plural is a special case because it uses a 's'
# by default.
- setattr(self, 'verbose_name_plural', meta_attrs.pop('verbose_name_plural', string_concat(self.verbose_name, 's')))
+ self.verbose_name_plural = meta_attrs.pop('verbose_name_plural', string_concat(self.verbose_name, 's'))
# Any leftover attributes must be invalid.
if meta_attrs != {}:
View
5 django/db/models/query_utils.py
@@ -257,9 +257,8 @@ def deferred_class_factory(model, attrs):
deferred attributes to a particular instance of the model.
"""
class Meta:
- pass
- setattr(Meta, "proxy", True)
- setattr(Meta, "app_label", model._meta.app_label)
+ proxy = True
+ app_label = model._meta.app_label
# The app_cache wants a unique name for each model, otherwise the new class
# won't be created (we get an old one back). Therefore, we generate the
View
2  django/forms/forms.py
@@ -268,7 +268,7 @@ def full_clean(self):
self._clean_form()
self._post_clean()
if self._errors:
- delattr(self, 'cleaned_data')
+ del self.cleaned_data
def _clean_fields(self):
for name, field in self.fields.items():
View
2  django/test/simple.py
@@ -58,7 +58,7 @@ def stoptest(test):
func(test)
return stoptest
- setattr(result, 'stopTest', stoptest_override(result.stopTest))
+ result.stopTest = stoptest_override(result.stopTest)
return result
def get_tests(app_module):
View
2  tests/regressiontests/comment_tests/tests/app_api_tests.py
@@ -41,7 +41,7 @@ def tearDown(self):
del settings.INSTALLED_APPS[-1]
settings.COMMENTS_APP = self.old_comments_app
if settings.COMMENTS_APP is None:
- delattr(settings._wrapped, 'COMMENTS_APP')
+ del settings._wrapped.COMMENTS_APP
def testGetCommentApp(self):
from regressiontests.comment_tests import custom_comments
Please sign in to comment.
Something went wrong with that request. Please try again.