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)
@ -72,12 +72,12 @@ class Command(NoArgsCommand):
# We want to honor both $PYTHONSTARTUP and .pythonrc.py, so follow system # We want to honor both $PYTHONSTARTUP and .pythonrc.py, so follow system
# conventions and get $PYTHONSTARTUP first then import user. # conventions and get $PYTHONSTARTUP first then import user.
if not use_plain: if not use_plain:
pythonrc = os.environ.get("PYTHONSTARTUP") pythonrc = os.environ.get("PYTHONSTARTUP")
if pythonrc and os.path.isfile(pythonrc): if pythonrc and os.path.isfile(pythonrc):
try: try:
execfile(pythonrc) execfile(pythonrc)
except NameError: except NameError:
pass pass
# This will import .pythonrc.py as a side-effect # This will import .pythonrc.py as a side-effect
import user import user

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

@ -51,7 +51,7 @@ class URLValidator(RegexValidator):
r'(?::\d+)?' # optional port r'(?::\d+)?' # optional port
r'(?:/?|[/?]\S+)$', re.IGNORECASE) r'(?:/?|[/?]\S+)$', re.IGNORECASE)
def __init__(self, verify_exists=False, def __init__(self, verify_exists=False,
validator_user_agent=URL_VALIDATOR_USER_AGENT): validator_user_agent=URL_VALIDATOR_USER_AGENT):
super(URLValidator, self).__init__() super(URLValidator, self).__init__()
self.verify_exists = verify_exists self.verify_exists = verify_exists
@ -99,7 +99,7 @@ class URLValidator(RegexValidator):
req.get_method = lambda: 'HEAD' req.get_method = lambda: 'HEAD'
#Create an opener that does not support local file access #Create an opener that does not support local file access
opener = urllib2.OpenerDirector() opener = urllib2.OpenerDirector()
#Don't follow redirects, but don't treat them as errors either #Don't follow redirects, but don't treat them as errors either
error_nop = lambda *args, **kwargs: True error_nop = lambda *args, **kwargs: True
http_error_processor = urllib2.HTTPErrorProcessor() http_error_processor = urllib2.HTTPErrorProcessor()
@ -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

@ -51,7 +51,7 @@ def token_kwargs(bits, parser, support_legacy=False):
kwargs = {} kwargs = {}
while bits: while bits:
if kwarg_format: if kwarg_format:
match = kwarg_re.match(bits[0]) match = kwarg_re.match(bits[0])
if not match or not match.group(1): if not match or not match.group(1):
return kwargs return kwargs
@ -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