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)
|
new_installed_apps.append(app)
|
||||||
self.INSTALLED_APPS = new_installed_apps
|
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
|
# When we can, attempt to validate the timezone. If we can't find
|
||||||
# this file, no check happens and it's harmless.
|
# this file, no check happens and it's harmless.
|
||||||
zoneinfo_root = '/usr/share/zoneinfo'
|
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)
|
fk = _get_foreign_key(parent_model, cls.model, fk_name=cls.fk_name, can_fail=True)
|
||||||
|
|
||||||
# extra = 3
|
# extra = 3
|
||||||
if not isinstance(getattr(cls, 'extra'), int):
|
if not isinstance(cls.extra, int):
|
||||||
raise ImproperlyConfigured("'%s.extra' should be a integer."
|
raise ImproperlyConfigured("'%s.extra' should be a integer."
|
||||||
% cls.__name__)
|
% cls.__name__)
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,12 @@ def load_backend(path):
|
||||||
cls = getattr(mod, attr)
|
cls = getattr(mod, attr)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise ImproperlyConfigured('Module "%s" does not define a "%s" authentication backend' % (module, attr))
|
raise ImproperlyConfigured('Module "%s" does not define a "%s" authentication backend' % (module, attr))
|
||||||
try:
|
if not hasattr(cls, "supports_object_permissions"):
|
||||||
getattr(cls, 'supports_object_permissions')
|
|
||||||
except AttributeError:
|
|
||||||
warn("Authentication backends without a `supports_object_permissions` attribute are deprecated. Please define it in %s." % cls,
|
warn("Authentication backends without a `supports_object_permissions` attribute are deprecated. Please define it in %s." % cls,
|
||||||
PendingDeprecationWarning)
|
PendingDeprecationWarning)
|
||||||
cls.supports_object_permissions = False
|
cls.supports_object_permissions = False
|
||||||
try:
|
|
||||||
getattr(cls, 'supports_anonymous_user')
|
if not hasattr(cls, 'supports_anonymous_user'):
|
||||||
except AttributeError:
|
|
||||||
warn("Authentication backends without a `supports_anonymous_user` attribute are deprecated. Please define it in %s." % cls,
|
warn("Authentication backends without a `supports_anonymous_user` attribute are deprecated. Please define it in %s." % cls,
|
||||||
PendingDeprecationWarning)
|
PendingDeprecationWarning)
|
||||||
cls.supports_anonymous_user = False
|
cls.supports_anonymous_user = False
|
||||||
|
|
|
@ -93,7 +93,7 @@ def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB
|
||||||
else:
|
else:
|
||||||
qs = klass._default_manager.using(using).all()
|
qs = klass._default_manager.using(using).all()
|
||||||
for mod in qs:
|
for mod in qs:
|
||||||
setattr(mod, 'kml', getattr(mod, field_name).kml)
|
mod.kml = getattr(mod, field_name).kml)
|
||||||
placemarks.append(mod)
|
placemarks.append(mod)
|
||||||
|
|
||||||
# Getting the render function and rendering to the correct.
|
# Getting the render function and rendering to the correct.
|
||||||
|
|
|
@ -63,7 +63,7 @@ def get_cache(backend_uri):
|
||||||
else:
|
else:
|
||||||
name = scheme
|
name = scheme
|
||||||
module = importlib.import_module(name)
|
module = importlib.import_module(name)
|
||||||
return getattr(module, 'CacheClass')(host, params)
|
return module.CacheClass(host, params)
|
||||||
|
|
||||||
cache = get_cache(settings.CACHE_BACKEND)
|
cache = get_cache(settings.CACHE_BACKEND)
|
||||||
|
|
||||||
|
|
|
@ -508,7 +508,7 @@ class Model(object):
|
||||||
# autopopulate the _order field
|
# autopopulate the _order field
|
||||||
field = meta.order_with_respect_to
|
field = meta.order_with_respect_to
|
||||||
order_value = manager.using(using).filter(**{field.name: getattr(self, field.attname)}).count()
|
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 not pk_set:
|
||||||
if force_update:
|
if force_update:
|
||||||
|
|
|
@ -79,14 +79,14 @@ class Options(object):
|
||||||
# unique_together can be either a tuple of tuples, or a single
|
# 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
|
# tuple of two strings. Normalize it to a tuple of tuples, so that
|
||||||
# calling code can uniformly expect 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)):
|
if ut and not isinstance(ut[0], (tuple, list)):
|
||||||
ut = (ut,)
|
ut = (ut,)
|
||||||
setattr(self, 'unique_together', ut)
|
self.unique_together = ut
|
||||||
|
|
||||||
# verbose_name_plural is a special case because it uses a 's'
|
# verbose_name_plural is a special case because it uses a 's'
|
||||||
# by default.
|
# 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.
|
# Any leftover attributes must be invalid.
|
||||||
if meta_attrs != {}:
|
if meta_attrs != {}:
|
||||||
|
|
|
@ -257,9 +257,8 @@ def deferred_class_factory(model, attrs):
|
||||||
deferred attributes to a particular instance of the model.
|
deferred attributes to a particular instance of the model.
|
||||||
"""
|
"""
|
||||||
class Meta:
|
class Meta:
|
||||||
pass
|
proxy = True
|
||||||
setattr(Meta, "proxy", True)
|
app_label = model._meta.app_label
|
||||||
setattr(Meta, "app_label", model._meta.app_label)
|
|
||||||
|
|
||||||
# The app_cache wants a unique name for each model, otherwise the new class
|
# 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
|
# 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._clean_form()
|
||||||
self._post_clean()
|
self._post_clean()
|
||||||
if self._errors:
|
if self._errors:
|
||||||
delattr(self, 'cleaned_data')
|
del self.cleaned_data
|
||||||
|
|
||||||
def _clean_fields(self):
|
def _clean_fields(self):
|
||||||
for name, field in self.fields.items():
|
for name, field in self.fields.items():
|
||||||
|
|
|
@ -58,7 +58,7 @@ class DjangoTestRunner(unittest.TextTestRunner):
|
||||||
func(test)
|
func(test)
|
||||||
return stoptest
|
return stoptest
|
||||||
|
|
||||||
setattr(result, 'stopTest', stoptest_override(result.stopTest))
|
result.stopTest = stoptest_override(result.stopTest)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_tests(app_module):
|
def get_tests(app_module):
|
||||||
|
|
|
@ -41,7 +41,7 @@ class CustomCommentTest(CommentTestCase):
|
||||||
del settings.INSTALLED_APPS[-1]
|
del settings.INSTALLED_APPS[-1]
|
||||||
settings.COMMENTS_APP = self.old_comments_app
|
settings.COMMENTS_APP = self.old_comments_app
|
||||||
if settings.COMMENTS_APP is None:
|
if settings.COMMENTS_APP is None:
|
||||||
delattr(settings._wrapped, 'COMMENTS_APP')
|
del settings._wrapped.COMMENTS_APP
|
||||||
|
|
||||||
def testGetCommentApp(self):
|
def testGetCommentApp(self):
|
||||||
from regressiontests.comment_tests import custom_comments
|
from regressiontests.comment_tests import custom_comments
|
||||||
|
|
Loading…
Reference in New Issue