diff options
| author | Joseph Kocherhans <joseph@jkocherhans.com> | 2008-03-13 06:14:26 +0000 |
|---|---|---|
| committer | Joseph Kocherhans <joseph@jkocherhans.com> | 2008-03-13 06:14:26 +0000 |
| commit | bfc5660c472ac2e52cc4fdec78315c87b01357de (patch) | |
| tree | 887c25472201f310cc5b95cb236cf5492af9bf57 /django/core | |
| parent | 304642769c5e0e704d0204bc241574c8c491cdf5 (diff) | |
newforms-admin: Merged from trunk up to [7232]
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7233 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core')
| -rw-r--r-- | django/core/handlers/base.py | 3 | ||||
| -rw-r--r-- | django/core/handlers/modpython.py | 7 | ||||
| -rw-r--r-- | django/core/mail.py | 8 | ||||
| -rw-r--r-- | django/core/management/color.py | 16 | ||||
| -rw-r--r-- | django/core/management/commands/loaddata.py | 30 | ||||
| -rw-r--r-- | django/core/management/commands/syncdb.py | 2 | ||||
| -rw-r--r-- | django/core/management/sql.py | 2 | ||||
| -rw-r--r-- | django/core/serializers/json.py | 1 | ||||
| -rw-r--r-- | django/core/serializers/pyyaml.py | 1 |
9 files changed, 47 insertions, 23 deletions
diff --git a/django/core/handlers/base.py b/django/core/handlers/base.py index 7f68946f3d..a81bec322f 100644 --- a/django/core/handlers/base.py +++ b/django/core/handlers/base.py @@ -109,7 +109,8 @@ class BaseHandler(object): except exceptions.PermissionDenied: return http.HttpResponseForbidden('<h1>Permission denied</h1>') except SystemExit: - pass # See http://code.djangoproject.com/ticket/1023 + # Allow sys.exit() to actually exit. See tickets #1023 and #4701 + raise except: # Handle everything else, including SuspiciousOperation, etc. # Get the exception info now, in case another exception is thrown later. exc_info = sys.exc_info() diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py index ebf79295e0..abab399009 100644 --- a/django/core/handlers/modpython.py +++ b/django/core/handlers/modpython.py @@ -6,7 +6,7 @@ from django.core import signals from django.core.handlers.base import BaseHandler from django.dispatch import dispatcher from django.utils import datastructures -from django.utils.encoding import force_unicode +from django.utils.encoding import force_unicode, smart_str # NOTE: do *not* import settings (or any module which eventually imports # settings) until after ModPythonHandler has been called; otherwise os.environ @@ -36,8 +36,9 @@ class ModPythonRequest(http.HttpRequest): meta = pformat(self.META) except: meta = '<could not parse>' - return '<ModPythonRequest\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % \ - (self.path, get, post, cookies, meta) + return smart_str(u'<ModPythonRequest\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % + (self.path, unicode(get), unicode(post), + unicode(cookies), unicode(meta))) def get_full_path(self): return '%s%s' % (self.path, self._req.args and ('?' + self._req.args) or '') diff --git a/django/core/mail.py b/django/core/mail.py index 153dcb6e63..72343cb4df 100644 --- a/django/core/mail.py +++ b/django/core/mail.py @@ -318,8 +318,8 @@ def send_mail(subject, message, from_email, recipient_list, fail_silently=False, If auth_user is None, the EMAIL_HOST_USER setting is used. If auth_password is None, the EMAIL_HOST_PASSWORD setting is used. - NOTE: This method is deprecated. It exists for backwards compatibility. - New code should use the EmailMessage class directly. + Note: The API for this method is frozen. New code wanting to extend the + functionality should use the EmailMessage class directly. """ connection = SMTPConnection(username=auth_user, password=auth_password, fail_silently=fail_silently) @@ -335,8 +335,8 @@ def send_mass_mail(datatuple, fail_silently=False, auth_user=None, auth_password If auth_user is None, the EMAIL_HOST_USER setting is used. If auth_password is None, the EMAIL_HOST_PASSWORD setting is used. - NOTE: This method is deprecated. It exists for backwards compatibility. - New code should use the EmailMessage class directly. + Note: The API for this method is frozen. New code wanting to extend the + functionality should use the EmailMessage class directly. """ connection = SMTPConnection(username=auth_user, password=auth_password, fail_silently=fail_silently) diff --git a/django/core/management/color.py b/django/core/management/color.py index 40fd4e7fdd..337e0f2e68 100644 --- a/django/core/management/color.py +++ b/django/core/management/color.py @@ -6,10 +6,22 @@ import sys from django.utils import termcolors +def supports_color(): + """ + Returns True if the running system's terminal supports color, and False + otherwise. + """ + unsupported_platform = (sys.platform in ('win32', 'Pocket PC') + or sys.platform.startswith('java')) + # isatty is not always implemented, #6223. + is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() + if unsupported_platform or not is_a_tty: + return False + return True + def color_style(): """Returns a Style object with the Django color scheme.""" - if (sys.platform == 'win32' or sys.platform == 'Pocket PC' - or sys.platform.startswith('java') or not sys.stdout.isatty()): + if not supports_color(): return no_style() class dummy: pass style = dummy() diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py index e95be6b8d7..d06b131d6f 100644 --- a/django/core/management/commands/loaddata.py +++ b/django/core/management/commands/loaddata.py @@ -30,7 +30,8 @@ class Command(BaseCommand): show_traceback = options.get('traceback', False) # Keep a count of the installed objects and fixtures - count = [0, 0] + fixture_count = 0 + object_count = 0 models = set() humanize = lambda dirname: dirname and "'%s'" % dirname or 'absolute path' @@ -65,7 +66,12 @@ class Command(BaseCommand): else: print "Skipping fixture '%s': %s is not a known serialization format" % (fixture_name, format) - for fixture_dir in app_fixtures + list(settings.FIXTURE_DIRS) + ['']: + if os.path.isabs(fixture_name): + fixture_dirs = [fixture_name] + else: + fixture_dirs = app_fixtures + list(settings.FIXTURE_DIRS) + [''] + + for fixture_dir in fixture_dirs: if verbosity > 1: print "Checking %s for fixtures..." % humanize(fixture_dir) @@ -86,14 +92,14 @@ class Command(BaseCommand): transaction.leave_transaction_management() return else: - count[1] += 1 + fixture_count += 1 if verbosity > 0: print "Installing %s fixture '%s' from %s." % \ (format, fixture_name, humanize(fixture_dir)) try: objects = serializers.deserialize(format, fixture) for obj in objects: - count[0] += 1 + object_count += 1 models.add(obj.object.__class__) obj.save() label_found = True @@ -102,10 +108,12 @@ class Command(BaseCommand): transaction.rollback() transaction.leave_transaction_management() if show_traceback: - raise - sys.stderr.write( - self.style.ERROR("Problem installing fixture '%s': %s\n" % - (full_path, str(e)))) + import traceback + traceback.print_exc() + else: + sys.stderr.write( + self.style.ERROR("Problem installing fixture '%s': %s\n" % + (full_path, str(e)))) return fixture.close() except: @@ -113,7 +121,7 @@ class Command(BaseCommand): print "No %s fixture '%s' in %s." % \ (format, fixture_name, humanize(fixture_dir)) - if count[0] > 0: + if object_count > 0: sequence_sql = connection.ops.sequence_reset_sql(self.style, models) if sequence_sql: if verbosity > 1: @@ -124,9 +132,9 @@ class Command(BaseCommand): transaction.commit() transaction.leave_transaction_management() - if count[0] == 0: + if object_count == 0: if verbosity >= 2: print "No fixtures found." else: if verbosity > 0: - print "Installed %d object(s) from %d fixture(s)" % tuple(count) + print "Installed %d object(s) from %d fixture(s)" % (object_count, fixture_count) diff --git a/django/core/management/commands/syncdb.py b/django/core/management/commands/syncdb.py index 0f21130f7a..8017ed832f 100644 --- a/django/core/management/commands/syncdb.py +++ b/django/core/management/commands/syncdb.py @@ -67,6 +67,8 @@ class Command(NoArgsCommand): created_models.add(model) for refto, refs in references.items(): pending_references.setdefault(refto, []).extend(refs) + if refto in seen_models: + sql.extend(sql_for_pending_references(refto, self.style, pending_references)) sql.extend(sql_for_pending_references(model, self.style, pending_references)) if verbosity >= 1: print "Creating table %s" % model._meta.db_table diff --git a/django/core/management/sql.py b/django/core/management/sql.py index 15bffce26b..ab3a7b64c5 100644 --- a/django/core/management/sql.py +++ b/django/core/management/sql.py @@ -90,6 +90,8 @@ def sql_create(app, style): final_output.extend(output) for refto, refs in references.items(): pending_references.setdefault(refto, []).extend(refs) + if refto in known_models: + final_output.extend(sql_for_pending_references(refto, style, pending_references)) final_output.extend(sql_for_pending_references(model, style, pending_references)) # Keep track of the fact that we've created the table for this model. known_models.add(model) diff --git a/django/core/serializers/json.py b/django/core/serializers/json.py index e17b821f52..20797c02f6 100644 --- a/django/core/serializers/json.py +++ b/django/core/serializers/json.py @@ -4,7 +4,6 @@ Serialize data to/from JSON import datetime from django.utils import simplejson -from django.utils.simplejson import decoder from django.core.serializers.python import Serializer as PythonSerializer from django.core.serializers.python import Deserializer as PythonDeserializer try: diff --git a/django/core/serializers/pyyaml.py b/django/core/serializers/pyyaml.py index 4c32a9686f..58cf59bed9 100644 --- a/django/core/serializers/pyyaml.py +++ b/django/core/serializers/pyyaml.py @@ -4,7 +4,6 @@ YAML serializer. Requires PyYaml (http://pyyaml.org/), but that's checked for in __init__. """ -import datetime from django.db import models from django.core.serializers.python import Serializer as PythonSerializer from django.core.serializers.python import Deserializer as PythonDeserializer |
