Kill some more dead code.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16795 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Alex Gaynor 2011-09-10 22:46:44 +00:00
parent 345c4c4629
commit 8e1226b4a0
8 changed files with 24 additions and 26 deletions

View File

@ -152,7 +152,7 @@ class BaseHandler(object):
try: try:
response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
finally: finally:
receivers = signals.got_request_exception.send(sender=self.__class__, request=request) signals.got_request_exception.send(sender=self.__class__, request=request)
except exceptions.PermissionDenied: except exceptions.PermissionDenied:
logger.warning( logger.warning(
'Forbidden (Permission denied): %s' % request.path, 'Forbidden (Permission denied): %s' % request.path,
@ -168,14 +168,14 @@ class BaseHandler(object):
response = self.handle_uncaught_exception(request, response = self.handle_uncaught_exception(request,
resolver, sys.exc_info()) resolver, sys.exc_info())
finally: finally:
receivers = signals.got_request_exception.send( signals.got_request_exception.send(
sender=self.__class__, request=request) sender=self.__class__, request=request)
except SystemExit: except SystemExit:
# Allow sys.exit() to actually exit. See tickets #1023 and #4701 # Allow sys.exit() to actually exit. See tickets #1023 and #4701
raise raise
except: # Handle everything else, including SuspiciousOperation, etc. except: # Handle everything else, including SuspiciousOperation, etc.
# Get the exception info now, in case another exception is thrown later. # Get the exception info now, in case another exception is thrown later.
receivers = signals.got_request_exception.send(sender=self.__class__, request=request) signals.got_request_exception.send(sender=self.__class__, request=request)
response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
finally: finally:
# Reset URLconf for this thread on the way out for complete # Reset URLconf for this thread on the way out for complete
@ -188,7 +188,7 @@ class BaseHandler(object):
response = middleware_method(request, response) response = middleware_method(request, response)
response = self.apply_response_fixes(request, response) response = self.apply_response_fixes(request, response)
except: # Any exception should be gathered and handled except: # Any exception should be gathered and handled
receivers = signals.got_request_exception.send(sender=self.__class__, request=request) signals.got_request_exception.send(sender=self.__class__, request=request)
response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
return response return response

View File

@ -420,7 +420,7 @@ def setup_environ(settings_mod, original_settings_path=None):
# Import the project module. We add the parent directory to PYTHONPATH to # Import the project module. We add the parent directory to PYTHONPATH to
# avoid some of the path errors new users can have. # avoid some of the path errors new users can have.
sys.path.append(os.path.join(project_directory, os.pardir)) sys.path.append(os.path.join(project_directory, os.pardir))
project_module = import_module(project_name) import_module(project_name)
sys.path.pop() sys.path.pop()
return project_directory return project_directory

View File

@ -1,7 +1,7 @@
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from django.core import serializers from django.core import serializers
from django.db import connections, router, DEFAULT_DB_ALIAS from django.db import router, DEFAULT_DB_ALIAS
from django.utils.datastructures import SortedDict from django.utils.datastructures import SortedDict
from optparse import make_option from optparse import make_option
@ -28,12 +28,11 @@ class Command(BaseCommand):
args = '[appname appname.ModelName ...]' args = '[appname appname.ModelName ...]'
def handle(self, *app_labels, **options): def handle(self, *app_labels, **options):
from django.db.models import get_app, get_apps, get_models, get_model from django.db.models import get_app, get_apps, get_model
format = options.get('format','json') format = options.get('format','json')
indent = options.get('indent',None) indent = options.get('indent',None)
using = options.get('database', DEFAULT_DB_ALIAS) using = options.get('database', DEFAULT_DB_ALIAS)
connection = connections[using]
excludes = options.get('exclude',[]) excludes = options.get('exclude',[])
show_traceback = options.get('traceback', False) show_traceback = options.get('traceback', False)
use_natural_keys = options.get('use_natural_keys', False) use_natural_keys = options.get('use_natural_keys', False)

View File

@ -44,7 +44,7 @@ class Command(NoArgsCommand):
# XXX: (Temporary) workaround for ticket #1796: force early loading of all # XXX: (Temporary) workaround for ticket #1796: force early loading of all
# models from installed apps. # models from installed apps.
from django.db.models.loading import get_models from django.db.models.loading import get_models
loaded_models = get_models() get_models()
use_plain = options.get('plain', False) use_plain = options.get('plain', False)

View File

@ -127,7 +127,6 @@ def sql_custom(app, style, connection):
output = [] output = []
app_models = get_models(app) app_models = get_models(app)
app_dir = os.path.normpath(os.path.join(os.path.dirname(app.__file__), 'sql'))
for model in app_models: for model in app_models:
output.extend(custom_sql_for_model(model, style, connection)) output.extend(custom_sql_for_model(model, style, connection))

View File

@ -114,10 +114,11 @@ class URLValidator(RegexValidator):
http_error_processor] http_error_processor]
try: try:
import ssl import ssl
handlers.append(urllib2.HTTPSHandler()) except ImportError:
except: # Python isn't compiled with SSL support
#Python isn't compiled with SSL support
pass pass
else:
handlers.append(urllib2.HTTPSHandler())
map(opener.add_handler, handlers) map(opener.add_handler, handlers)
opener.http_error_301 = lambda: True opener.http_error_301 = lambda: True
if platform.python_version_tuple() >= (2, 6): if platform.python_version_tuple() >= (2, 6):
@ -133,7 +134,7 @@ class URLValidator(RegexValidator):
def validate_integer(value): def validate_integer(value):
try: try:
int(value) int(value)
except (ValueError, TypeError), e: except (ValueError, TypeError):
raise ValidationError('') raise ValidationError('')
class EmailValidator(RegexValidator): class EmailValidator(RegexValidator):
@ -145,7 +146,6 @@ class EmailValidator(RegexValidator):
# Trivial case failed. Try for possible IDN domain-part # Trivial case failed. Try for possible IDN domain-part
if value and u'@' in value: if value and u'@' in value:
parts = value.split(u'@') parts = value.split(u'@')
domain_part = parts[-1]
try: try:
parts[-1] = parts[-1].encode('idna') parts[-1] = parts[-1].encode('idna')
except UnicodeError: except UnicodeError:

View File

@ -607,7 +607,8 @@ def unordered_list(value, autoescape=None):
if second_item == []: if second_item == []:
return [first_item], True return [first_item], True
try: try:
it = iter(second_item) # see if second item is iterable # see if second item is iterable
iter(second_item)
except TypeError: except TypeError:
return list_, False return list_, False
old_style_list = True old_style_list = True

View File

@ -276,7 +276,6 @@ class IfChangedNode(Node):
compare_to = None compare_to = None
if compare_to != self._last_seen: if compare_to != self._last_seen:
firstloop = (self._last_seen == None)
self._last_seen = compare_to self._last_seen = compare_to
content = self.nodelist_true.render(context) content = self.nodelist_true.render(context)
return content return content