mirror of https://github.com/django/django.git
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
This commit is contained in:
parent
d8d38ec6e7
commit
1df1378f9e
|
@ -102,7 +102,7 @@ class Settings(object):
|
|||
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'
|
||||
|
|
|
@ -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__)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -508,7 +508,7 @@ class Model(object):
|
|||
# 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:
|
||||
|
|
|
@ -79,14 +79,14 @@ class Options(object):
|
|||
# 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 != {}:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -268,7 +268,7 @@ class BaseForm(StrAndUnicode):
|
|||
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():
|
||||
|
|
|
@ -58,7 +58,7 @@ class DjangoTestRunner(unittest.TextTestRunner):
|
|||
func(test)
|
||||
return stoptest
|
||||
|
||||
setattr(result, 'stopTest', stoptest_override(result.stopTest))
|
||||
result.stopTest = stoptest_override(result.stopTest)
|
||||
return result
|
||||
|
||||
def get_tests(app_module):
|
||||
|
|
|
@ -41,7 +41,7 @@ class CustomCommentTest(CommentTestCase):
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue