Commits

Anonymous committed e8c67a5

gis: Merged revisions 7837-7838,7842-7852,7856-7869,7871,7876-7877,7882-7891,7900-7917 via svnmerge from trunk.

  • Participants
  • Parent commits aa62228
  • Branches gis

Comments (0)

Files changed (82)

     andy@jadedplanet.net
     Fabrice Aneche <akh@nobugware.com>
     ant9000@netwise.it
-    Florian Apolloner
+    Florian Apolloner <florian@apolloner.eu>
     arien <regexbot@gmail.com>
     David Ascher <http://ascher.ca/>
     Jökull Sólberg Auðunsson <jokullsolberg@gmail.com>
     Neal Norwitz <nnorwitz@google.com>
     Todd O'Bryan <toddobryan@mac.com>
     oggie rob <oz.robharvey@gmail.com>
+    oggy <ognjen.maric@gmail.com>
     Jay Parlar <parlar@gmail.com>
     Carlos Eduardo de Paula <carlosedp@gmail.com>
     pavithran s <pavithran.s@gmail.com>
     Swaroop C H <http://www.swaroopch.info>
     Aaron Swartz <http://www.aaronsw.com/>
     Ville Säävuori <http://www.unessa.net/>
+    Christian Tanzer <tanzer@swing.co.at>
     Tyler Tarabula <tyler.tarabula@gmail.com>
     Tyson Tate <tyson@fallingbullets.com>
     Frank Tegtmeyer <fte@fte.to>

django/bin/compile-messages.py

 #!/usr/bin/env python
 
-import optparse
-import os
-import sys
+if __name__ == "__main__":
+    import sys
+    name = sys.argv[0]
+    args = ' '.join(sys.argv[1:])
+    print >> sys.stderr, "%s has been moved into django-admin.py" % name
+    print >> sys.stderr, 'Please run "django-admin.py compilemessages %s" instead.'% args
+    print >> sys.stderr
+    sys.exit(1)
 
-try:
-    set
-except NameError:
-    from sets import Set as set     # For Python 2.3
-
-
-def compile_messages(locale=None):
-    basedirs = (os.path.join('conf', 'locale'), 'locale')
-    if os.environ.get('DJANGO_SETTINGS_MODULE'):
-        from django.conf import settings
-        basedirs += settings.LOCALE_PATHS
-
-    # Gather existing directories.
-    basedirs = set(map(os.path.abspath, filter(os.path.isdir, basedirs)))
-
-    if not basedirs:
-        print "This script should be run from the Django SVN tree or your project or app tree, or with the settings module specified."
-        sys.exit(1)
-
-    for basedir in basedirs:
-        if locale:
-            basedir = os.path.join(basedir, locale, 'LC_MESSAGES')
-        compile_messages_in_dir(basedir)
-
-def compile_messages_in_dir(basedir):
-    for dirpath, dirnames, filenames in os.walk(basedir):
-        for f in filenames:
-            if f.endswith('.po'):
-                sys.stderr.write('processing file %s in %s\n' % (f, dirpath))
-                pf = os.path.splitext(os.path.join(dirpath, f))[0]
-                # Store the names of the .mo and .po files in an environment
-                # variable, rather than doing a string replacement into the
-                # command, so that we can take advantage of shell quoting, to
-                # quote any malicious characters/escaping.
-                # See http://cyberelk.net/tim/articles/cmdline/ar01s02.html
-                os.environ['djangocompilemo'] = pf + '.mo'
-                os.environ['djangocompilepo'] = pf + '.po'
-                if sys.platform == 'win32': # Different shell-variable syntax
-                    cmd = 'msgfmt --check-format -o "%djangocompilemo%" "%djangocompilepo%"'
-                else:
-                    cmd = 'msgfmt --check-format -o "$djangocompilemo" "$djangocompilepo"'
-                os.system(cmd)
-
-def main():
-    parser = optparse.OptionParser()
-    parser.add_option('-l', '--locale', dest='locale',
-            help="The locale to process. Default is to process all.")
-    parser.add_option('--settings',
-        help='Python path to settings module, e.g. "myproject.settings". If provided, all LOCALE_PATHS will be processed. If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be checked as well.')
-    options, args = parser.parse_args()
-    if len(args):
-        parser.error("This program takes no arguments")
-    if options.settings:
-        os.environ['DJANGO_SETTINGS_MODULE'] = options.settings
-    compile_messages(options.locale)
-
-if __name__ == "__main__":
-    main()

django/bin/daily_cleanup.py

 sessions at the moment).
 """
 
-import datetime
-from django.db import transaction
-from django.contrib.sessions.models import Session
-
-def clean_up():
-    """Clean up expired sessions."""
-    Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()
-    transaction.commit_unless_managed()
+from django.core import management
 
 if __name__ == "__main__":
-    clean_up()
+    management.call_command('cleanup')

django/bin/make-messages.py

 #!/usr/bin/env python
 
-# Need to ensure that the i18n framework is enabled
-from django.conf import settings
-settings.configure(USE_I18N = True)
+if __name__ == "__main__":
+    import sys
+    name = sys.argv[0]
+    args = ' '.join(sys.argv[1:])
+    print >> sys.stderr, "%s has been moved into django-admin.py" % name
+    print >> sys.stderr, 'Please run "django-admin.py makemessages %s" instead.'% args
+    print >> sys.stderr
+    sys.exit(1)
 
-from django.utils.translation import templatize
-import re
-import os
-import sys
-import getopt
-from itertools import dropwhile
-
-pythonize_re = re.compile(r'\n\s*//')
-
-def make_messages():
-    localedir = None
-
-    if os.path.isdir(os.path.join('conf', 'locale')):
-        localedir = os.path.abspath(os.path.join('conf', 'locale'))
-    elif os.path.isdir('locale'):
-        localedir = os.path.abspath('locale')
-    else:
-        print "This script should be run from the django svn tree or your project or app tree."
-        print "If you did indeed run it from the svn checkout or your project or application,"
-        print "maybe you are just missing the conf/locale (in the django tree) or locale (for project"
-        print "and application) directory?"
-        print "make-messages.py doesn't create it automatically, you have to create it by hand if"
-        print "you want to enable i18n for your project or application."
-        sys.exit(1)
-
-    (opts, args) = getopt.getopt(sys.argv[1:], 'l:d:va')
-
-    lang = None
-    domain = 'django'
-    verbose = False
-    all = False
-
-    for o, v in opts:
-        if o == '-l':
-            lang = v
-        elif o == '-d':
-            domain = v
-        elif o == '-v':
-            verbose = True
-        elif o == '-a':
-            all = True
-
-    if domain not in ('django', 'djangojs'):
-        print "currently make-messages.py only supports domains 'django' and 'djangojs'"
-        sys.exit(1)
-    if (lang is None and not all) or domain is None:
-        print "usage: make-messages.py -l <language>"
-        print "   or: make-messages.py -a"
-        sys.exit(1)
-
-    languages = []
-
-    if lang is not None:
-        languages.append(lang)
-    elif all:
-        languages = [el for el in os.listdir(localedir) if not el.startswith('.')]
-
-    for lang in languages:
-
-        print "processing language", lang
-        basedir = os.path.join(localedir, lang, 'LC_MESSAGES')
-        if not os.path.isdir(basedir):
-            os.makedirs(basedir)
-
-        pofile = os.path.join(basedir, '%s.po' % domain)
-        potfile = os.path.join(basedir, '%s.pot' % domain)
-
-        if os.path.exists(potfile):
-            os.unlink(potfile)
-
-        all_files = []
-        for (dirpath, dirnames, filenames) in os.walk("."):
-            all_files.extend([(dirpath, f) for f in filenames])
-        all_files.sort()
-        for dirpath, file in all_files:
-            if domain == 'djangojs' and file.endswith('.js'):
-                if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
-                src = open(os.path.join(dirpath, file), "rb").read()
-                src = pythonize_re.sub('\n#', src)
-                open(os.path.join(dirpath, '%s.py' % file), "wb").write(src)
-                thefile = '%s.py' % file
-                cmd = 'xgettext -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (domain, os.path.join(dirpath, thefile))
-                (stdin, stdout, stderr) = os.popen3(cmd, 't')
-                msgs = stdout.read()
-                errors = stderr.read()
-                if errors:
-                    print "errors happened while running xgettext on %s" % file
-                    print errors
-                    sys.exit(8)
-                old = '#: '+os.path.join(dirpath, thefile)[2:]
-                new = '#: '+os.path.join(dirpath, file)[2:]
-                msgs = msgs.replace(old, new)
-                if os.path.exists(potfile):
-                    # Strip the header
-                    msgs = '\n'.join(dropwhile(len, msgs.split('\n')))
-                else:
-                    msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8')
-                if msgs:
-                    open(potfile, 'ab').write(msgs)
-                os.unlink(os.path.join(dirpath, thefile))
-            elif domain == 'django' and (file.endswith('.py') or file.endswith('.html')):
-                thefile = file
-                if file.endswith('.html'):
-                    src = open(os.path.join(dirpath, file), "rb").read()
-                    thefile = '%s.py' % file
-                    open(os.path.join(dirpath, thefile), "wb").write(templatize(src))
-                if verbose:
-                    sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
-                cmd = 'xgettext -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --keyword=ugettext_noop --keyword=ugettext_lazy --keyword=ungettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (
-                    domain, os.path.join(dirpath, thefile))
-                (stdin, stdout, stderr) = os.popen3(cmd, 't')
-                msgs = stdout.read()
-                errors = stderr.read()
-                if errors:
-                    print "errors happened while running xgettext on %s" % file
-                    print errors
-                    sys.exit(8)
-                if thefile != file:
-                    old = '#: '+os.path.join(dirpath, thefile)[2:]
-                    new = '#: '+os.path.join(dirpath, file)[2:]
-                    msgs = msgs.replace(old, new)
-                if os.path.exists(potfile):
-                    # Strip the header
-                    msgs = '\n'.join(dropwhile(len, msgs.split('\n')))
-                else:
-                    msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8')
-                if msgs:
-                    open(potfile, 'ab').write(msgs)
-                if thefile != file:
-                    os.unlink(os.path.join(dirpath, thefile))
-
-        if os.path.exists(potfile):
-            (stdin, stdout, stderr) = os.popen3('msguniq --to-code=utf-8 "%s"' % potfile, 'b')
-            msgs = stdout.read()
-            errors = stderr.read()
-            if errors:
-                print "errors happened while running msguniq"
-                print errors
-                sys.exit(8)
-            open(potfile, 'w').write(msgs)
-            if os.path.exists(pofile):
-                (stdin, stdout, stderr) = os.popen3('msgmerge -q "%s" "%s"' % (pofile, potfile), 'b')
-                msgs = stdout.read()
-                errors = stderr.read()
-                if errors:
-                    print "errors happened while running msgmerge"
-                    print errors
-                    sys.exit(8)
-            open(pofile, 'wb').write(msgs)
-            os.unlink(potfile)
-
-if __name__ == "__main__":
-    make_messages()

django/conf/__init__.py

             setattr(holder, name, value)
         self._target = holder
 
+    def configured(self):
+        """
+        Returns True if the settings have already been configured.
+        """
+        return bool(self._target)
+    configured = property(configured)
+
 class Settings(object):
     def __init__(self, settings_module):
         # update this dict from global settings (but only for ALL_CAPS settings)

django/conf/locale/it/LC_MESSAGES/django.mo

Binary file modified.

django/conf/locale/it/LC_MESSAGES/django.po

 msgstr ""
 "Project-Id-Version: Django vSVN\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-06-02 18:40+0200\n"
-"PO-Revision-Date: 2008-05-18 19:13+0200\n"
+"POT-Creation-Date: 2008-07-12 20:30+0200\n"
+"PO-Revision-Date: 2008-07-12 20:45+0200\n"
 "Last-Translator: Nicola Larosa <nico@tekNico.net>\n"
 "Language-Team: Italiano\n"
 "MIME-Version: 1.0\n"
 "X-Generator: KBabel 1.11.4\n"
 "Plural-Forms:  nplurals=2; plural=(n != 1);\n"
 
-#: conf/global_settings.py:43
+#: conf/global_settings.py:44
 msgid "Arabic"
 msgstr "Arabo"
 
-#: conf/global_settings.py:44
+#: conf/global_settings.py:45
 msgid "Bengali"
 msgstr "Bengali"
 
-#: conf/global_settings.py:45
+#: conf/global_settings.py:46
 msgid "Bulgarian"
 msgstr "Bulgaro"
 
-#: conf/global_settings.py:46
+#: conf/global_settings.py:47
 msgid "Catalan"
 msgstr "Catalano"
 
-#: conf/global_settings.py:47
+#: conf/global_settings.py:48
 msgid "Czech"
 msgstr "Ceco"
 
-#: conf/global_settings.py:48
+#: conf/global_settings.py:49
 msgid "Welsh"
 msgstr "Gallese"
 
-#: conf/global_settings.py:49
+#: conf/global_settings.py:50
 msgid "Danish"
 msgstr "Danese"
 
-#: conf/global_settings.py:50
+#: conf/global_settings.py:51
 msgid "German"
 msgstr "Tedesco"
 
-#: conf/global_settings.py:51
+#: conf/global_settings.py:52
 msgid "Greek"
 msgstr "Greco"
 
-#: conf/global_settings.py:52
+#: conf/global_settings.py:53
 msgid "English"
 msgstr "Inglese"
 
-#: conf/global_settings.py:53
+#: conf/global_settings.py:54
 msgid "Spanish"
 msgstr "Spagnolo"
 
-#: conf/global_settings.py:54
+#: conf/global_settings.py:55
+msgid "Estonian"
+msgstr "Estone"
+
+#: conf/global_settings.py:56
 msgid "Argentinean Spanish"
 msgstr "Spagnolo argentino"
 
-#: conf/global_settings.py:55
+#: conf/global_settings.py:57
 msgid "Basque"
 msgstr "Basco"
 
-#: conf/global_settings.py:56
+#: conf/global_settings.py:58
 msgid "Persian"
 msgstr "Persiano"
 
-#: conf/global_settings.py:57
+#: conf/global_settings.py:59
 msgid "Finnish"
 msgstr "Finlandese"
 
-#: conf/global_settings.py:58
+#: conf/global_settings.py:60
 msgid "French"
 msgstr "Francese"
 
-#: conf/global_settings.py:59
+#: conf/global_settings.py:61
 msgid "Irish"
 msgstr "Irlandese"
 
-#: conf/global_settings.py:60
+#: conf/global_settings.py:62
 msgid "Galician"
 msgstr "Galiziano"
 
-#: conf/global_settings.py:61
+#: conf/global_settings.py:63
 msgid "Hungarian"
 msgstr "Ungherese"
 
-#: conf/global_settings.py:62
+#: conf/global_settings.py:64
 msgid "Hebrew"
 msgstr "Ebraico"
 
-#: conf/global_settings.py:63
+#: conf/global_settings.py:65
 msgid "Croatian"
 msgstr "Croato"
 
-#: conf/global_settings.py:64
+#: conf/global_settings.py:66
 msgid "Icelandic"
 msgstr "Islandese"
 
-#: conf/global_settings.py:65
+#: conf/global_settings.py:67
 msgid "Italian"
 msgstr "Italiano"
 
-#: conf/global_settings.py:66
+#: conf/global_settings.py:68
 msgid "Japanese"
 msgstr "Giapponese"
 
-#: conf/global_settings.py:67
+#: conf/global_settings.py:69
 msgid "Georgian"
 msgstr "Georgiano"
 
-#: conf/global_settings.py:68
+#: conf/global_settings.py:70
 msgid "Korean"
 msgstr "Coreano"
 
-#: conf/global_settings.py:69
+#: conf/global_settings.py:71
 msgid "Khmer"
 msgstr "Khmer"
 
-#: conf/global_settings.py:70
+#: conf/global_settings.py:72
 msgid "Kannada"
 msgstr "Kannada"
 
-#: conf/global_settings.py:71
+#: conf/global_settings.py:73
 msgid "Latvian"
 msgstr "Lettone"
 
-#: conf/global_settings.py:72
+#: conf/global_settings.py:74
+msgid "Lithuanian"
+msgstr "Lituano"
+
+#: conf/global_settings.py:75
 msgid "Macedonian"
 msgstr "Macedone"
 
-#: conf/global_settings.py:73
+#: conf/global_settings.py:76
 msgid "Dutch"
 msgstr "Olandese"
 
-#: conf/global_settings.py:74
+#: conf/global_settings.py:77
 msgid "Norwegian"
 msgstr "Norvegese"
 
-#: conf/global_settings.py:75
+#: conf/global_settings.py:78
 msgid "Polish"
 msgstr "Polacco"
 
-#: conf/global_settings.py:76
+#: conf/global_settings.py:79
 msgid "Portugese"
 msgstr "Portoghese"
 
-#: conf/global_settings.py:77
+#: conf/global_settings.py:80
 msgid "Brazilian Portuguese"
 msgstr "Brasiliano Portoghese"
 
-#: conf/global_settings.py:78
+#: conf/global_settings.py:81
 msgid "Romanian"
 msgstr "Rumeno"
 
-#: conf/global_settings.py:79
+#: conf/global_settings.py:82
 msgid "Russian"
 msgstr "Russo"
 
-#: conf/global_settings.py:80
+#: conf/global_settings.py:83
 msgid "Slovak"
 msgstr "Slovacco"
 
-#: conf/global_settings.py:81
+#: conf/global_settings.py:84
 msgid "Slovenian"
 msgstr "Sloveno"
 
-#: conf/global_settings.py:82
+#: conf/global_settings.py:85
 msgid "Serbian"
 msgstr "Serbo"
 
-#: conf/global_settings.py:83
+#: conf/global_settings.py:86
 msgid "Swedish"
 msgstr "Svedese"
 
-#: conf/global_settings.py:84
+#: conf/global_settings.py:87
 msgid "Tamil"
 msgstr "Tamil"
 
-#: conf/global_settings.py:85
+#: conf/global_settings.py:88
 msgid "Telugu"
 msgstr "Telugu"
 
-#: conf/global_settings.py:86
+#: conf/global_settings.py:89
 msgid "Turkish"
 msgstr "Turco"
 
-#: conf/global_settings.py:87
+#: conf/global_settings.py:90
 msgid "Ukrainian"
 msgstr "Ucraino"
 
-#: conf/global_settings.py:88
+#: conf/global_settings.py:91
 msgid "Simplified Chinese"
 msgstr "Cinese semplificato"
 
-#: conf/global_settings.py:89
+#: conf/global_settings.py:92
 msgid "Traditional Chinese"
 msgstr "Cinese tradizionale"
 
 msgid "group"
 msgstr "gruppo"
 
-#: contrib/auth/models.py:98 contrib/auth/models.py:141
+#: contrib/auth/models.py:98 contrib/auth/models.py:148
 msgid "groups"
 msgstr "gruppi"
 
-#: contrib/auth/models.py:131
+#: contrib/auth/models.py:138
 msgid "username"
 msgstr "nome utente"
 
-#: contrib/auth/models.py:131
+#: contrib/auth/models.py:138
 msgid ""
 "Required. 30 characters or fewer. Alphanumeric characters only (letters, "
 "digits and underscores)."
 "Obbligatorio. 30 caratteri o meno. Solo caratteri alfanumerici (lettere, "
 "cifre e sottolineati)."
 
-#: contrib/auth/models.py:132
+#: contrib/auth/models.py:139
 msgid "first name"
 msgstr "nome"
 
-#: contrib/auth/models.py:133
+#: contrib/auth/models.py:140
 msgid "last name"
 msgstr "cognome"
 
-#: contrib/auth/models.py:134
+#: contrib/auth/models.py:141
 msgid "e-mail address"
 msgstr "indirizzo e-mail"
 
-#: contrib/auth/models.py:135
+#: contrib/auth/models.py:142
 msgid "password"
 msgstr "password"
 
-#: contrib/auth/models.py:135
+#: contrib/auth/models.py:142
 msgid ""
 "Use '[algo]$[salt]$[hexdigest]' or use the <a href=\"password/\">change "
 "password form</a>."
 "Usare '[algo]$[salt]$[hexdigest]' oppure la <a href=\"password/\">maschera "
 "di cambio password</a>."
 
-#: contrib/auth/models.py:136
+#: contrib/auth/models.py:143
 msgid "staff status"
 msgstr "privilegi di staff"
 
-#: contrib/auth/models.py:136
+#: contrib/auth/models.py:143
 msgid "Designates whether the user can log into this admin site."
 msgstr "Indica se l'utente può accedere a questo sito di amministrazione."
 
-#: contrib/auth/models.py:137
+#: contrib/auth/models.py:144
 msgid "active"
 msgstr "attivo"
 
-#: contrib/auth/models.py:137
+#: contrib/auth/models.py:144
 msgid ""
 "Designates whether this user should be treated as active. Unselect this "
 "instead of deleting accounts."
 "Indica se l'utente debba essere considerato attivo. Deselezionare "
 "qui, piuttosto che cancellare gli account."
 
-#: contrib/auth/models.py:138
+#: contrib/auth/models.py:145
 msgid "superuser status"
 msgstr "privilegi di superutente"
 
-#: contrib/auth/models.py:138
+#: contrib/auth/models.py:145
 msgid ""
 "Designates that this user has all permissions without explicitly assigning "
 "them."
 "Indica che l'utente ha tutti i privilegi, senza che siano stati assegnati "
 "esplicitamente."
 
-#: contrib/auth/models.py:139
+#: contrib/auth/models.py:146
 msgid "last login"
 msgstr "ultimo accesso"
 
-#: contrib/auth/models.py:140
+#: contrib/auth/models.py:147
 msgid "date joined"
 msgstr "iscritto in data"
 
-#: contrib/auth/models.py:142
+#: contrib/auth/models.py:149
 msgid ""
 "In addition to the permissions manually assigned, this user will also get "
 "all permissions granted to each group he/she is in."
 "In aggiunta ai privilegi assegnati manualmente, l'utente riceverà anche "
 "tutti i privilegi assegnati ad ogni gruppo cui appartiene."
 
-#: contrib/auth/models.py:143
+#: contrib/auth/models.py:150
 msgid "user permissions"
 msgstr "privilegi utente"
 
-#: contrib/auth/models.py:147
+#: contrib/auth/models.py:154
 msgid "user"
 msgstr "utente"
 
-#: contrib/auth/models.py:148
+#: contrib/auth/models.py:155
 msgid "users"
 msgstr "utenti"
 
-#: contrib/auth/models.py:154
+#: contrib/auth/models.py:160
 msgid "Personal info"
 msgstr "Informazioni personali"
 
-#: contrib/auth/models.py:155
+#: contrib/auth/models.py:161
 msgid "Permissions"
 msgstr "Permessi"
 
-#: contrib/auth/models.py:156
+#: contrib/auth/models.py:162
 msgid "Important dates"
 msgstr "Date importanti"
 
-#: contrib/auth/models.py:157
+#: contrib/auth/models.py:163
 msgid "Groups"
 msgstr "Gruppi"
 
-#: contrib/auth/models.py:316
+#: contrib/auth/models.py:323
 msgid "message"
 msgstr "messaggio"
 
-#: contrib/auth/views.py:47
+#: contrib/auth/views.py:49
 msgid "Logged out"
 msgstr "Accesso annullato"
 
 msgid "redirects"
 msgstr "redirezioni"
 
-#: contrib/sessions/models.py:41
+#: contrib/sessions/models.py:45
 msgid "session key"
 msgstr "chiave di sessione"
 
-#: contrib/sessions/models.py:42
+#: contrib/sessions/models.py:47
 msgid "session data"
 msgstr "dati di sessione"
 
-#: contrib/sessions/models.py:43
+#: contrib/sessions/models.py:48
 msgid "expire date"
 msgstr "data di scadenza"
 
-#: contrib/sessions/models.py:48
+#: contrib/sessions/models.py:53
 msgid "session"
 msgstr "sessione"
 
-#: contrib/sessions/models.py:49
+#: contrib/sessions/models.py:54
 msgid "sessions"
 msgstr "sessioni"
 
 msgid "This value can't be comprised solely of digits."
 msgstr "Questo valore non può essere composto solo da cifre."
 
-#: core/validators.py:128 newforms/fields.py:152
+#: core/validators.py:128 newforms/fields.py:157
 msgid "Enter a whole number."
 msgstr "Inserire un numero intero."
 
 msgid "Invalid date: %s"
 msgstr "Data non valida: %s"
 
-#: core/validators.py:156 db/models/fields/__init__.py:548
+#: core/validators.py:156 db/models/fields/__init__.py:554
 msgid "Enter a valid date in YYYY-MM-DD format."
 msgstr "Inserire una data valida in formato AAAA-MM-GG."
 
 msgid "Enter a valid time in HH:MM format."
 msgstr "Inserire un ora valida in formato OO:MM."
 
-#: core/validators.py:165 db/models/fields/__init__.py:625
+#: core/validators.py:165 db/models/fields/__init__.py:631
 msgid "Enter a valid date/time in YYYY-MM-DD HH:MM format."
 msgstr "Inserire una data/ora valida in formato AAAA-MM-GG OO:MM."
 
-#: core/validators.py:170 newforms/fields.py:403
+#: core/validators.py:170 newforms/fields.py:408
 msgid "Enter a valid e-mail address."
 msgstr "Inserire un indirizzo e-mail valido."
 
-#: core/validators.py:182 core/validators.py:474 newforms/fields.py:433
-#: oldforms/__init__.py:687
+#: core/validators.py:182 core/validators.py:474 newforms/fields.py:426
 msgid "No file was submitted. Check the encoding type on the form."
 msgstr "Non è stato inviato alcun file. Verificare il tipo di codifica della form."
 
-#: core/validators.py:193 newforms/fields.py:459
+#: core/validators.py:193 newforms/fields.py:468
 msgid ""
 "Upload a valid image. The file you uploaded was either not an image or a "
 "corrupted image."
 msgid "%(object)s with this %(type)s already exists for the given %(field)s."
 msgstr "Un %(object)s·con questo·%(type)s·esiste già per questo·%(field)s."
 
-#: db/models/fields/__init__.py:54
+#: db/models/fields/__init__.py:52
 #, python-format
 msgid "%(optname)s with this %(fieldname)s already exists."
 msgstr "Un %(optname)s·con questo·%(fieldname)s·esiste già."
 
-#: db/models/fields/__init__.py:179 db/models/fields/__init__.py:348
-#: db/models/fields/__init__.py:780 db/models/fields/__init__.py:791
-#: newforms/fields.py:46 oldforms/__init__.py:374
+#: db/models/fields/__init__.py:182 db/models/fields/__init__.py:354
+#: db/models/fields/__init__.py:788 db/models/fields/__init__.py:799
+#: newforms/fields.py:51 oldforms/__init__.py:374
 msgid "This field is required."
 msgstr "Questo campo è obbligatorio."
 
-#: db/models/fields/__init__.py:448
+#: db/models/fields/__init__.py:454
 msgid "This value must be an integer."
 msgstr "Questo valore deve essere un intero."
 
-#: db/models/fields/__init__.py:487
+#: db/models/fields/__init__.py:493
 msgid "This value must be either True or False."
 msgstr "Questo valore deve essere True o False."
 
-#: db/models/fields/__init__.py:511
+#: db/models/fields/__init__.py:517
 msgid "This field cannot be null."
 msgstr "Questo campo non può essere nullo."
 
-#: db/models/fields/__init__.py:689
+#: db/models/fields/__init__.py:695
 msgid "This value must be a decimal number."
 msgstr "Questo valore deve essere un numero decimale."
 
-#: db/models/fields/__init__.py:800
+#: db/models/fields/__init__.py:808
 msgid "Enter a valid filename."
 msgstr "Inserire un nome di file valido."
 
-#: db/models/fields/__init__.py:981
+#: db/models/fields/__init__.py:999
 msgid "This value must be either None, True or False."
 msgstr "Questo valore deve essere None, True o False."
 
 msgid "Please enter a valid %s."
 msgstr "Inserire un %s valido."
 
-#: db/models/fields/related.py:721
+#: db/models/fields/related.py:756
 msgid "Separate multiple IDs with commas."
 msgstr "Separare gli ID multipli con virgole."
 
-#: db/models/fields/related.py:723
+#: db/models/fields/related.py:758
 msgid "Hold down \"Control\", or \"Command\" on a Mac, to select more than one."
 msgstr ""
 "Tenere premuto \"Control\", o \"Command\" su Mac, per selezionarne più di "
 "uno."
 
-#: db/models/fields/related.py:770
+#: db/models/fields/related.py:805
 #, python-format
 msgid "Please enter valid %(self)s IDs. The value %(value)r is invalid."
 msgid_plural "Please enter valid %(self)s IDs. The values %(value)r are invalid."
 msgstr[0] "Inserire un ID valido per %(self)s. Il valore %(value)r non è valido."
 msgstr[1] "Inserire ID validi per %(self)s. I valori %(value)r non sono validi."
 
-#: newforms/fields.py:47
+#: newforms/fields.py:52
 msgid "Enter a valid value."
 msgstr "Inserire un valore valido."
 
-#: newforms/fields.py:124
+#: newforms/fields.py:129
 #, python-format
 msgid "Ensure this value has at most %(max)d characters (it has %(length)d)."
 msgstr ""
 "Assicurarsi che questo valore non contenga più di %(max)d caratteri (ne ha %"
 "(length)d)."
 
-#: newforms/fields.py:125
+#: newforms/fields.py:130
 #, python-format
 msgid "Ensure this value has at least %(min)d characters (it has %(length)d)."
 msgstr ""
 "Assicurarsi che questo valore contenga almeno %(min)d caratteri (ne ha %"
 "(length)d)."
 
-#: newforms/fields.py:153 newforms/fields.py:182 newforms/fields.py:211
+#: newforms/fields.py:158 newforms/fields.py:187 newforms/fields.py:216
 #, python-format
 msgid "Ensure this value is less than or equal to %s."
 msgstr "Assicurarsi che questo valore sia minore o uguale a %s."
 
-#: newforms/fields.py:154 newforms/fields.py:183 newforms/fields.py:212
+#: newforms/fields.py:159 newforms/fields.py:188 newforms/fields.py:217
 #, python-format
 msgid "Ensure this value is greater than or equal to %s."
 msgstr "Assicurarsi che questo valore sia maggiore o uguale a %s."
 
-#: newforms/fields.py:181 newforms/fields.py:210
+#: newforms/fields.py:186 newforms/fields.py:215
 msgid "Enter a number."
 msgstr "Inserire un numero."
 
-#: newforms/fields.py:213
+#: newforms/fields.py:218
 #, python-format
 msgid "Ensure that there are no more than %s digits in total."
 msgstr "Assicurarsi che non vi siano più di %s cifre in totale."
 
-#: newforms/fields.py:214
+#: newforms/fields.py:219
 #, python-format
 msgid "Ensure that there are no more than %s decimal places."
 msgstr "Assicurarsi che non vi siano più di %s cifre decimali."
 
-#: newforms/fields.py:215
+#: newforms/fields.py:220
 #, python-format
 msgid "Ensure that there are no more than %s digits before the decimal point."
 msgstr "Assicurarsi che non vi siano più di %s cifre prima della virgola."
 
-#: newforms/fields.py:263 newforms/fields.py:751
+#: newforms/fields.py:268 newforms/fields.py:779
 msgid "Enter a valid date."
 msgstr "Inserire una data valida."
 
-#: newforms/fields.py:296 newforms/fields.py:752
+#: newforms/fields.py:301 newforms/fields.py:780
 msgid "Enter a valid time."
 msgstr "Inserire un ora valida."
 
-#: newforms/fields.py:335
+#: newforms/fields.py:340
 msgid "Enter a valid date/time."
 msgstr "Inserire una coppia data/ora valida."
 
-#: newforms/fields.py:434
+#: newforms/fields.py:427
 msgid "No file was submitted."
 msgstr "Nessun file è stato inviato."
 
-#: newforms/fields.py:435 oldforms/__init__.py:689
+#: newforms/fields.py:428 oldforms/__init__.py:693
 msgid "The submitted file is empty."
 msgstr "Il file inviato è vuoto."
 
-#: newforms/fields.py:497
+#: newforms/fields.py:522
 msgid "Enter a valid URL."
 msgstr "Inserire una URL valida."
 
-#: newforms/fields.py:498
+#: newforms/fields.py:523
 msgid "This URL appears to be a broken link."
 msgstr "Questa URL non sembra funzionare."
 
-#: newforms/fields.py:560 newforms/models.py:299
+#: newforms/fields.py:588 newforms/models.py:306
 msgid "Select a valid choice. That choice is not one of the available choices."
 msgstr ""
 "Scegliere un'opzione valida. La scelta effettuata non compare tra quelle "
 "disponibili."
 
-#: newforms/fields.py:599
+#: newforms/fields.py:627
 #, python-format
 msgid "Select a valid choice. %(value)s is not one of the available choices."
 msgstr "Scegliere un'opzione valida. '%(value)s non compare tra quelle disponibili."
 
-#: newforms/fields.py:600 newforms/fields.py:662 newforms/models.py:371
+#: newforms/fields.py:628 newforms/fields.py:690 newforms/models.py:373
 msgid "Enter a list of values."
 msgstr "Inserire una lista di valori."
 
-#: newforms/fields.py:780
+#: newforms/fields.py:808
 msgid "Enter a valid IPv4 address."
 msgstr "Inserire un indirizzo IPv4 valido."
 
-#: newforms/models.py:372
+#: newforms/models.py:374
 #, python-format
 msgid "Select a valid choice. %s is not one of the available choices."
 msgstr "Scegliere un'opzione valida. '%s non compare tra quelle disponibili."
 msgid "Select a valid choice; '%(data)s' is not in %(choices)s."
 msgstr "Scegliere un'opzione valida; '%(data)s' non presente in %(choices)s."
 
-#: oldforms/__init__.py:745
+#: oldforms/__init__.py:754
 msgid "Enter a whole number between -32,768 and 32,767."
 msgstr "Inserire un numero intero compreso tra -32.768 e 32.767 ."
 
-#: oldforms/__init__.py:755
+#: oldforms/__init__.py:764
 msgid "Enter a positive number."
 msgstr "Inserire un numero positivo."
 
-#: oldforms/__init__.py:765
+#: oldforms/__init__.py:774
 msgid "Enter a whole number between 0 and 32,767."
 msgstr "Inserire un numero intero compreso tra 0 e 32.767 ."
 
 msgid "Dec."
 msgstr "Dic."
 
-#: utils/text.py:127
+#: utils/text.py:128
 msgid "or"
 msgstr "o"
 
 msgid ", %(number)d %(type)s"
 msgstr ", %(number)d %(type)s"
 
-#: utils/translation/trans_real.py:403
+#: utils/translation/trans_real.py:412
 msgid "DATE_FORMAT"
 msgstr "j F Y"
 
-#: utils/translation/trans_real.py:404
+#: utils/translation/trans_real.py:413
 msgid "DATETIME_FORMAT"
 msgstr "j F Y, H:i"
 
-#: utils/translation/trans_real.py:405
+#: utils/translation/trans_real.py:414
 msgid "TIME_FORMAT"
 msgstr "H:i"
 
-#: utils/translation/trans_real.py:421
+#: utils/translation/trans_real.py:430
 msgid "YEAR_MONTH_FORMAT"
 msgstr "Y F"
 
-#: utils/translation/trans_real.py:422
+#: utils/translation/trans_real.py:431
 msgid "MONTH_DAY_FORMAT"
 msgstr "F j"
 

django/contrib/admin/views/main.py

 from django.views.decorators.cache import never_cache
 from django.contrib.contenttypes.models import ContentType
 from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist, PermissionDenied
-from django.core.paginator import QuerySetPaginator, InvalidPage
+from django.core.paginator import Paginator, InvalidPage
 from django.shortcuts import get_object_or_404, render_to_response
 from django.db import models
 from django.db.models.query import QuerySet
         return mark_safe('?' + '&amp;'.join([u'%s=%s' % (k, v) for k, v in p.items()]).replace(' ', '%20'))
 
     def get_results(self, request):
-        paginator = QuerySetPaginator(self.query_set, self.lookup_opts.admin.list_per_page)
+        paginator = Paginator(self.query_set, self.lookup_opts.admin.list_per_page)
 
         # Get the number of objects, with admin filters applied.
         try:

django/core/context_processors.py

     return context_extras
 
 def i18n(request):
+    from django.utils import translation
+
     context_extras = {}
     context_extras['LANGUAGES'] = settings.LANGUAGES
-    if hasattr(request, 'LANGUAGE_CODE'):
-        context_extras['LANGUAGE_CODE'] = request.LANGUAGE_CODE
-    else:
-        context_extras['LANGUAGE_CODE'] = settings.LANGUAGE_CODE
-
-    from django.utils import translation
+    context_extras['LANGUAGE_CODE'] = translation.get_language()
     context_extras['LANGUAGE_BIDI'] = translation.get_language_bidi()
 
     return context_extras

django/core/files/uploadedfile.py

 """
 
 import os
+import tempfile
+import warnings
 try:
     from cStringIO import StringIO
 except ImportError:
     from StringIO import StringIO
 
-__all__ = ('UploadedFile', 'TemporaryUploadedFile', 'InMemoryUploadedFile')
+from django.conf import settings
+
+__all__ = ('UploadedFile', 'TemporaryUploadedFile', 'InMemoryUploadedFile', 'SimpleUploadedFile')
+
+# Because we fooled around with it a bunch, UploadedFile has a bunch
+# of deprecated properties. This little shortcut helps define 'em
+# without too much code duplication.
+def deprecated_property(old, new, readonly=False):
+    def issue_warning():
+        warnings.warn(
+            message = "UploadedFile.%s is deprecated; use UploadedFile.%s instead." % (old, new),
+            category = DeprecationWarning,
+            stacklevel = 3
+        )
+    
+    def getter(self):
+        issue_warning()
+        return getattr(self, new)
+        
+    def setter(self, value):
+        issue_warning()
+        setattr(self, new, value)
+        
+    if readonly:
+        return property(getter)
+    else:
+        return property(getter, setter)
 
 class UploadedFile(object):
     """
     """
     DEFAULT_CHUNK_SIZE = 64 * 2**10
 
-    def __init__(self, file_name=None, content_type=None, file_size=None, charset=None):
-        self.file_name = file_name
-        self.file_size = file_size
+    def __init__(self, name=None, content_type=None, size=None, charset=None):
+        self.name = name
+        self.size = size
         self.content_type = content_type
         self.charset = charset
 
     def __repr__(self):
-        return "<%s: %s (%s)>" % (self.__class__.__name__, self.file_name, self.content_type)
+        return "<%s: %s (%s)>" % (self.__class__.__name__, self.name, self.content_type)
 
-    def _set_file_name(self, name):
+    def _get_name(self):
+        return self._name
+
+    def _set_name(self, name):
         # Sanitize the file name so that it can't be dangerous.
         if name is not None:
             # Just use the basename of the file -- anything else is dangerous.
             name = os.path.basename(name)
-            
+
             # File names longer than 255 characters can cause problems on older OSes.
             if len(name) > 255:
                 name, ext = os.path.splitext(name)
                 name = name[:255 - len(ext)] + ext
-                
-        self._file_name = name
-        
-    def _get_file_name(self):
-        return self._file_name
-        
-    file_name = property(_get_file_name, _set_file_name)
 
-    def chunk(self, chunk_size=None):
+        self._name = name
+
+    name = property(_get_name, _set_name)
+
+    def chunks(self, chunk_size=None):
         """
         Read the file and yield chucks of ``chunk_size`` bytes (defaults to
         ``UploadedFile.DEFAULT_CHUNK_SIZE``).
         if hasattr(self, 'seek'):
             self.seek(0)
         # Assume the pointer is at zero...
-        counter = self.file_size
+        counter = self.size
 
         while counter > 0:
             yield self.read(chunk_size)
             counter -= chunk_size
 
+    # Deprecated properties
+    filename = deprecated_property(old="filename", new="name")
+    file_name = deprecated_property(old="file_name", new="name")
+    file_size = deprecated_property(old="file_size", new="size")
+    chunk = deprecated_property(old="chunk", new="chunks", readonly=True)
+
+    def _get_data(self):
+        warnings.warn(
+            message = "UploadedFile.data is deprecated; use UploadedFile.read() instead.",
+            category = DeprecationWarning,
+            stacklevel = 2
+        )
+        return self.read()
+    data = property(_get_data)
+
     def multiple_chunks(self, chunk_size=None):
         """
         Returns ``True`` if you can expect multiple chunks.
         """
         if not chunk_size:
             chunk_size = UploadedFile.DEFAULT_CHUNK_SIZE
-        return self.file_size < chunk_size
+        return self.size > chunk_size
 
-    # Abstract methods; subclasses *must* default read() and probably should
+    # Abstract methods; subclasses *must* define read() and probably should
     # define open/close.
     def read(self, num_bytes=None):
         raise NotImplementedError()
     def close(self):
         pass
 
+    def xreadlines(self):
+        return self
+
+    def readlines(self):
+        return list(self.xreadlines())
+
+    def __iter__(self):
+        # Iterate over this file-like object by newlines
+        buffer_ = None
+        for chunk in self.chunks():
+            chunk_buffer = StringIO(chunk)
+
+            for line in chunk_buffer:
+                if buffer_:
+                    line = buffer_ + line
+                    buffer_ = None
+
+                # If this is the end of a line, yield
+                # otherwise, wait for the next round
+                if line[-1] in ('\n', '\r'):
+                    yield line
+                else:
+                    buffer_ = line
+
+        if buffer_ is not None:
+            yield buffer_
+
     # Backwards-compatible support for uploaded-files-as-dictionaries.
     def __getitem__(self, key):
-        import warnings
         warnings.warn(
             message = "The dictionary access of uploaded file objects is deprecated. Use the new object interface instead.",
             category = DeprecationWarning,
             stacklevel = 2
         )
         backwards_translate = {
-            'filename': 'file_name',
+            'filename': 'name',
             'content-type': 'content_type',
-            }
+        }
 
         if key == 'content':
             return self.read()
         elif key == 'filename':
-            return self.file_name
+            return self.name
         elif key == 'content-type':
             return self.content_type
         else:
     """
     A file uploaded to a temporary location (i.e. stream-to-disk).
     """
-
-    def __init__(self, file, file_name, content_type, file_size, charset):
-        super(TemporaryUploadedFile, self).__init__(file_name, content_type, file_size, charset)
-        self.file = file
-        self.path = file.name
-        self.file.seek(0)
+    def __init__(self, name, content_type, size, charset):
+        super(TemporaryUploadedFile, self).__init__(name, content_type, size, charset)
+        if settings.FILE_UPLOAD_TEMP_DIR:
+            self._file = tempfile.NamedTemporaryFile(suffix='.upload', dir=settings.FILE_UPLOAD_TEMP_DIR)
+        else:
+            self._file = tempfile.NamedTemporaryFile(suffix='.upload')
 
     def temporary_file_path(self):
         """
         Returns the full path of this file.
         """
-        return self.path
-
-    def read(self, *args, **kwargs):
-        return self.file.read(*args, **kwargs)
-
-    def open(self):
-        self.seek(0)
-
-    def seek(self, *args, **kwargs):
-        self.file.seek(*args, **kwargs)
+        return self._file.name
+    
+    # Most methods on this object get proxied to NamedTemporaryFile.
+    # We can't directly subclass because NamedTemporaryFile is actually a
+    # factory function
+    def read(self, *args):          return self._file.read(*args)
+    def seek(self, offset):         return self._file.seek(offset)
+    def write(self, s):             return self._file.write(s)
+    def close(self):                return self._file.close()
+    def __iter__(self):             return iter(self._file)
+    def readlines(self, size=None): return self._file.readlines(size)
+    def xreadlines(self):           return self._file.xreadlines()
 
 class InMemoryUploadedFile(UploadedFile):
     """
     A file uploaded into memory (i.e. stream-to-memory).
     """
-    def __init__(self, file, field_name, file_name, content_type, file_size, charset):
-        super(InMemoryUploadedFile, self).__init__(file_name, content_type, file_size, charset)
+    def __init__(self, file, field_name, name, content_type, size, charset):
+        super(InMemoryUploadedFile, self).__init__(name, content_type, size, charset)
         self.file = file
         self.field_name = field_name
         self.file.seek(0)
     def read(self, *args, **kwargs):
         return self.file.read(*args, **kwargs)
 
-    def chunk(self, chunk_size=None):
+    def chunks(self, chunk_size=None):
         self.file.seek(0)
         yield self.read()
 
     """
     def __init__(self, name, content, content_type='text/plain'):
         self.file = StringIO(content or '')
-        self.file_name = name
+        self.name = name
         self.field_name = None
-        self.file_size = len(content or '')
+        self.size = len(content or '')
         self.content_type = content_type
         self.charset = None
         self.file.seek(0)

django/core/files/uploadhandler.py

         Create the file object to append to as data is coming in.
         """
         super(TemporaryFileUploadHandler, self).new_file(file_name, *args, **kwargs)
-        self.file = TemporaryFile(settings.FILE_UPLOAD_TEMP_DIR)
-        self.write = self.file.write
+        self.file = TemporaryUploadedFile(self.file_name, self.content_type, 0, self.charset)
 
     def receive_data_chunk(self, raw_data, start):
-        self.write(raw_data)
+        self.file.write(raw_data)
 
     def file_complete(self, file_size):
         self.file.seek(0)
-        return TemporaryUploadedFile(
-            file = self.file, 
-            file_name = self.file_name, 
-            content_type = self.content_type, 
-            file_size = file_size, 
-            charset = self.charset
-        )
+        self.file.size = file_size
+        return self.file
 
 class MemoryFileUploadHandler(FileUploadHandler):
     """
         return InMemoryUploadedFile(
             file = self.file,
             field_name = self.field_name,
-            file_name = self.file_name,
+            name = self.file_name,
             content_type = self.content_type,
-            file_size = file_size,
+            size = file_size,
             charset = self.charset
         )
 
-class TemporaryFile(object):
-    """
-    A temporary file that tries to delete itself when garbage collected.
-    """
-    def __init__(self, dir):
-        if not dir:
-            dir = tempfile.gettempdir()
-        try:
-            (fd, name) = tempfile.mkstemp(suffix='.upload', dir=dir)
-            self.file = os.fdopen(fd, 'w+b')
-        except (OSError, IOError):
-            raise OSError("Could not create temporary file for uploading, have you set settings.FILE_UPLOAD_TEMP_DIR correctly?")
-        self.name = name
-
-    def __getattr__(self, name):
-        a = getattr(self.__dict__['file'], name)
-        if type(a) != type(0):
-            setattr(self, name, a)
-        return a
-
-    def __del__(self):
-        try:
-            os.unlink(self.name)
-        except OSError:
-            pass
 
 def load_handler(path, *args, **kwargs):
     """

django/core/handlers/base.py

 
 class BaseHandler(object):
     # Changes that are always applied to a response (in this order).
-    response_fixes = [http.fix_location_header,
-            http.conditional_content_removal]
+    response_fixes = [
+        http.fix_location_header,
+        http.conditional_content_removal,
+        http.fix_IE_for_attach,
+        http.fix_IE_for_vary,
+    ]
 
     def __init__(self):
         self._request_middleware = self._view_middleware = self._response_middleware = self._exception_middleware = None

django/core/mail.py

         conversions.
         """
         if to:
+            assert not isinstance(to, basestring), '"to" argument must be a list or tuple'
             self.to = list(to)
         else:
             self.to = []
         if bcc:
+            assert not isinstance(bcc, basestring), '"bcc" argument must be a list or tuple'
             self.bcc = list(bcc)
         else:
             self.bcc = []

django/core/management/__init__.py

     """
     def error(self, msg):
         pass
+    
+    def _process_args(self, largs, rargs, values):
+        """
+        Overrides OptionParser._process_args to exclusively handle default
+        options and ignore args and other options. 
+        
+        This overrides the behavior of the super class, which stop parsing 
+        at the first unrecognized option.
+        """
+        while rargs:
+            arg = rargs[0]
+            try:
+                if arg[0:2] == "--" and len(arg) > 2:
+                    # process a single long option (possibly with value(s))
+                    # the superclass code pops the arg off rargs
+                    self._process_long_opt(rargs, values)
+                elif arg[:1] == "-" and len(arg) > 1:
+                    # process a cluster of short options (possibly with
+                    # value(s) for the last one only)
+                    # the superclass code pops the arg off rargs
+                    self._process_short_opts(rargs, values)
+                else:
+                    # it's either a non-default option or an arg
+                    # either way, add it to the args list so we can keep
+                    # dealing with options
+                    del rargs[0]
+                    raise error
+            except:
+                largs.append(arg)
 
 class ManagementUtility(object):
     """

django/core/management/base.py

 from django.core.exceptions import ImproperlyConfigured
 from django.core.management.color import color_style
 
+try:
+    set
+except NameError:
+    from sets import Set as set     # For Python 2.3
+
 class CommandError(Exception):
     pass
 

django/core/management/commands/cleanup.py

+import datetime
+from django.core.management.base import NoArgsCommand
+
+class Command(NoArgsCommand):
+    help = "Can be run as a cronjob or directly to clean out old data from the database (only expired sessions at the moment)."
+
+    def handle_noargs(self, **options):
+        from django.db import transaction
+        from django.contrib.sessions.models import Session
+        Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()
+        transaction.commit_unless_managed()

django/core/management/commands/compilemessages.py

+import os
+import sys
+from optparse import make_option
+from django.core.management.base import BaseCommand
+from django.core.management.color import no_style
+
+try:
+    set
+except NameError:
+    from sets import Set as set     # For Python 2.3
+
+def compile_messages(locale=None):
+    basedirs = (os.path.join('conf', 'locale'), 'locale')
+    if os.environ.get('DJANGO_SETTINGS_MODULE'):
+        from django.conf import settings
+        basedirs += settings.LOCALE_PATHS
+
+    # Gather existing directories.
+    basedirs = set(map(os.path.abspath, filter(os.path.isdir, basedirs)))
+
+    if not basedirs:
+        raise CommandError("This script should be run from the Django SVN tree or your project or app tree, or with the settings module specified.")
+
+    for basedir in basedirs:
+        if locale:
+            basedir = os.path.join(basedir, locale, 'LC_MESSAGES')
+        for dirpath, dirnames, filenames in os.walk(basedir):
+            for f in filenames:
+                if f.endswith('.po'):
+                    sys.stderr.write('processing file %s in %s\n' % (f, dirpath))
+                    pf = os.path.splitext(os.path.join(dirpath, f))[0]
+                    # Store the names of the .mo and .po files in an environment
+                    # variable, rather than doing a string replacement into the
+                    # command, so that we can take advantage of shell quoting, to
+                    # quote any malicious characters/escaping.
+                    # See http://cyberelk.net/tim/articles/cmdline/ar01s02.html
+                    os.environ['djangocompilemo'] = pf + '.mo'
+                    os.environ['djangocompilepo'] = pf + '.po'
+                    if sys.platform == 'win32': # Different shell-variable syntax
+                        cmd = 'msgfmt --check-format -o "%djangocompilemo%" "%djangocompilepo%"'
+                    else:
+                        cmd = 'msgfmt --check-format -o "$djangocompilemo" "$djangocompilepo"'
+                    os.system(cmd)
+
+
+class Command(BaseCommand):
+    option_list = BaseCommand.option_list + (
+        make_option('--locale', '-l', dest='locale',
+            help='The locale to process. Default is to process all.'),
+    )
+    help = 'Compiles .po files to .mo files for use with builtin gettext support.'
+
+    requires_model_validation = False
+    can_import_settings = False
+
+    def handle(self, **options):
+        locale = options.get('locale')
+        compile_messages(locale)

django/core/management/commands/makemessages.py

+import re
+import os
+import sys
+from itertools import dropwhile
+from optparse import make_option
+from django.core.management.base import CommandError, BaseCommand
+
+pythonize_re = re.compile(r'\n\s*//')
+
+def make_messages(locale=None, domain='django', verbosity='1', all=False):
+    """
+    Uses the locale directory from the Django SVN tree or an application/
+    project to process all
+    """
+    # Need to ensure that the i18n framework is enabled
+    from django.conf import settings
+    if settings.configured:
+        settings.USE_I18N = True
+    else:
+        settings.configure(USE_I18N = True)
+
+    from django.utils.translation import templatize
+
+    if os.path.isdir(os.path.join('conf', 'locale')):
+        localedir = os.path.abspath(os.path.join('conf', 'locale'))
+    elif os.path.isdir('locale'):
+        localedir = os.path.abspath('locale')
+    else:
+        raise CommandError("This script should be run from the Django SVN tree or your project or app tree. If you did indeed run it from the SVN checkout or your project or application, maybe you are just missing the conf/locale (in the django tree) or locale (for project and application) directory? It is not created automatically, you have to create it by hand if you want to enable i18n for your project or application.")
+
+    if domain not in ('django', 'djangojs'):
+        raise CommandError("currently makemessages only supports domains 'django' and 'djangojs'")
+
+    if (locale is None and not all) or domain is None:
+        # backwards compatible error message
+        if not sys.argv[0].endswith("make-messages.py"):
+            message = "Type '%s help %s' for usage.\n" % (os.path.basename(sys.argv[0]), sys.argv[1])
+        else:
+            message = "usage: make-messages.py -l <language>\n   or: make-messages.py -a\n"
+        raise CommandError(message)
+
+    languages = []
+    if locale is not None:
+        languages.append(locale)
+    elif all:
+        languages = [el for el in os.listdir(localedir) if not el.startswith('.')]
+
+    for locale in languages:
+        if verbosity > 0:
+            print "processing language", locale
+        basedir = os.path.join(localedir, locale, 'LC_MESSAGES')
+        if not os.path.isdir(basedir):
+            os.makedirs(basedir)
+
+        pofile = os.path.join(basedir, '%s.po' % domain)
+        potfile = os.path.join(basedir, '%s.pot' % domain)
+
+        if os.path.exists(potfile):
+            os.unlink(potfile)
+
+        all_files = []
+        for (dirpath, dirnames, filenames) in os.walk("."):
+            all_files.extend([(dirpath, f) for f in filenames])
+        all_files.sort()
+        for dirpath, file in all_files:
+            if domain == 'djangojs' and file.endswith('.js'):
+                if verbosity > 1:
+                    sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
+                src = open(os.path.join(dirpath, file), "rb").read()
+                src = pythonize_re.sub('\n#', src)
+                open(os.path.join(dirpath, '%s.py' % file), "wb").write(src)
+                thefile = '%s.py' % file
+                cmd = 'xgettext -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (domain, os.path.join(dirpath, thefile))
+                (stdin, stdout, stderr) = os.popen3(cmd, 't')
+                msgs = stdout.read()
+                errors = stderr.read()
+                if errors:
+                    raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors))
+                old = '#: '+os.path.join(dirpath, thefile)[2:]
+                new = '#: '+os.path.join(dirpath, file)[2:]
+                msgs = msgs.replace(old, new)
+                if os.path.exists(potfile):
+                    # Strip the header
+                    msgs = '\n'.join(dropwhile(len, msgs.split('\n')))
+                else:
+                    msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8')
+                if msgs:
+                    open(potfile, 'ab').write(msgs)
+                os.unlink(os.path.join(dirpath, thefile))
+            elif domain == 'django' and (file.endswith('.py') or file.endswith('.html')):
+                thefile = file
+                if file.endswith('.html'):
+                    src = open(os.path.join(dirpath, file), "rb").read()
+                    thefile = '%s.py' % file
+                    open(os.path.join(dirpath, thefile), "wb").write(templatize(src))
+                if verbosity > 1:
+                    sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
+                cmd = 'xgettext -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --keyword=ugettext_noop --keyword=ugettext_lazy --keyword=ungettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (
+                    domain, os.path.join(dirpath, thefile))
+                (stdin, stdout, stderr) = os.popen3(cmd, 't')
+                msgs = stdout.read()
+                errors = stderr.read()
+                if errors:
+                    raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors))
+                if thefile != file:
+                    old = '#: '+os.path.join(dirpath, thefile)[2:]
+                    new = '#: '+os.path.join(dirpath, file)[2:]
+                    msgs = msgs.replace(old, new)
+                if os.path.exists(potfile):
+                    # Strip the header
+                    msgs = '\n'.join(dropwhile(len, msgs.split('\n')))
+                else:
+                    msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8')
+                if msgs:
+                    open(potfile, 'ab').write(msgs)
+                if thefile != file:
+                    os.unlink(os.path.join(dirpath, thefile))
+
+        if os.path.exists(potfile):
+            (stdin, stdout, stderr) = os.popen3('msguniq --to-code=utf-8 "%s"' % potfile, 'b')
+            msgs = stdout.read()
+            errors = stderr.read()
+            if errors:
+                raise CommandError("errors happened while running msguniq\n%s" % errors)
+            open(potfile, 'w').write(msgs)
+            if os.path.exists(pofile):
+                (stdin, stdout, stderr) = os.popen3('msgmerge -q "%s" "%s"' % (pofile, potfile), 'b')
+                msgs = stdout.read()
+                errors = stderr.read()
+                if errors:
+                    raise CommandError("errors happened while running msgmerge\n%s" % errors)
+            open(pofile, 'wb').write(msgs)
+            os.unlink(potfile)
+
+
+class Command(BaseCommand):
+    option_list = BaseCommand.option_list + (
+        make_option('--locale', '-l', default=None, dest='locale',
+            help='Creates or updates the message files only for the given locale (e.g. pt_BR).'),
+        make_option('--domain', '-d', default='django', dest='domain',
+            help='The domain of the message files (default: "django").'),
+        make_option('--verbosity', '-v', action='store', dest='verbosity',
+            default='1', type='choice', choices=['0', '1', '2'],
+            help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'),
+        make_option('--all', '-a', action='store_true', dest='all',
+            default=False, help='Reexamines all source code and templates for new translation strings and updates all message files for all available languages.'),
+    )
+    help = "Runs over the entire source tree of the current directory and pulls out all strings marked for translation. It creates (or updates) a message file in the conf/locale (in the django tree) or locale (for project and application) directory."
+
+    requires_model_validation = False
+    can_import_settings = False
+
+    def handle(self, *args, **options):
+        if len(args) != 0:
+            raise CommandError("Command doesn't accept any arguments")
+
+        locale = options.get('locale')
+        domain = options.get('domain')
+        verbosity = int(options.get('verbosity'))
+        process_all = options.get('all')
+
+        make_messages(locale, domain, verbosity, process_all)

django/core/management/commands/syncdb.py

                 # but raises an ImportError for some reason. The only way we
                 # can do this is to check the text of the exception. Note that
                 # we're a bit broad in how we check the text, because different
-                # Python implementations may not use the same text. CPython
-                # uses the text "No module named management".
+                # Python implementations may not use the same text. 
+                # CPython uses the text "No module named management"
+                # PyPy uses "No module named myproject.myapp.management"
                 msg = exc.args[0]
-                if not msg.startswith('No module named management') or 'management' not in msg:
+                if not msg.startswith('No module named') or 'management' not in msg:
                     raise
 
         cursor = connection.cursor()
         # Send the post_syncdb signal, so individual apps can do whatever they need
         # to do at this point.
         emit_post_sync_signal(created_models, verbosity, interactive)
-
+        
+        # The connection may have been closed by a syncdb handler.
+        cursor = connection.cursor()
+        
         # Install custom SQL for the app (but only if this
         # is a model we've just created)
         for app in models.get_apps():
                             for sql in index_sql:
                                 cursor.execute(sql)
                         except Exception, e:
-                            sys.stderr.write("Failed to install index for %s.%s model: %s" % \
+                            sys.stderr.write("Failed to install index for %s.%s model: %s\n" % \
                                                 (app_name, model._meta.object_name, e))
                             transaction.rollback_unless_managed()
                         else:

django/core/paginator.py

 class InvalidPage(Exception):
     pass
 
+class PageNotAnInteger(InvalidPage):
+    pass
+
+class EmptyPage(InvalidPage):
+    pass
+
 class Paginator(object):
     def __init__(self, object_list, per_page, orphans=0, allow_empty_first_page=True):
         self.object_list = object_list
         try:
             number = int(number)
         except ValueError:
-            raise InvalidPage('That page number is not an integer')
+            raise PageNotAnInteger('That page number is not an integer')
         if number < 1:
-            raise InvalidPage('That page number is less than 1')
+            raise EmptyPage('That page number is less than 1')
         if number > self.num_pages:
             if number == 1 and self.allow_empty_first_page:
                 pass
             else:
-                raise InvalidPage('That page contains no results')
+                raise EmptyPage('That page contains no results')
         return number
 
     def page(self, number):
     def _get_count(self):
         "Returns the total number of objects, across all pages."
         if self._count is None:
-            self._count = len(self.object_list)
+            from django.db.models.query import QuerySet
+            if isinstance(self.object_list, QuerySet):
+                self._count = self.object_list.count()
+            else:
+                self._count = len(self.object_list)
         return self._count
     count = property(_get_count)
 
         return range(1, self.num_pages + 1)
     page_range = property(_get_page_range)
 
-class QuerySetPaginator(Paginator):
-    """
-    Like Paginator, but works on QuerySets.
-    """
-    def _get_count(self):
-        if self._count is None:
-            self._count = self.object_list.count()
-        return self._count
-    count = property(_get_count)
+QuerySetPaginator = Paginator # For backwards-compatibility.
 
 class Page(object):
     def __init__(self, object_list, number, paginator):
         try:
             page_number = int(page_number) + 1
         except ValueError:
-            raise InvalidPage
+            raise PageNotAnInteger
         return self.validate_number(page_number)
 
     def get_page(self, page_number):
         try:
             page_number = int(page_number) + 1
         except ValueError:
-            raise InvalidPage
+