Django

Code

Changeset 6459

Show
Ignore:
Timestamp:
10/06/07 17:34:48 (1 year ago)
Author:
jkocherhans
Message:

newforms-admin: Merged to [6458]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/newforms-admin

    • Property svnmerge-integrated changed from /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-6390,6392-6416 to /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-6390,6392-6456
  • django/branches/newforms-admin/AUTHORS

    r6417 r6459  
    116116    A. Murat Eren <meren@pardus.org.tr> 
    117117    Ludvig Ericson <ludvig.ericson@gmail.com> 
     118    eriks@win.tue.nl 
    118119    Dirk Eschler <dirk.eschler@gmx.net> 
    119120    Marc Fargas <telenieko@telenieko.com> 
     
    240241    pavithran s <pavithran.s@gmail.com> 
    241242    Barry Pederson <bp@barryp.org> 
     243    permonik@mesias.brnonet.cz 
    242244    petr.marhoun@gmail.com 
    243245    pgross@thoughtworks.com 
     
    318320    Milton Waddams 
    319321    wam-djangobug@wamber.net 
    320     wangchun <yaohua2000@gmail.com
     322    Wang Chun <wangchun@exoweb.net
    321323    Filip Wasilewski <filip.wasilewski@gmail.com> 
    322324    Dan Watson <http://theidioteque.net/> 
  • django/branches/newforms-admin/django/bin/compile-messages.py

    r6371 r6459  
    1515    if os.environ.get('DJANGO_SETTINGS_MODULE'): 
    1616        from django.conf import settings 
    17         basedirs += settings.LOCALE_PATHS 
     17        if hasattr(settings, 'LOCALE_PATHS'): 
     18            basedirs += settings.LOCALE_PATHS 
    1819 
    1920    # Gather existing directories. 
  • django/branches/newforms-admin/django/bin/make-messages.py

    r5918 r6459  
    7575            os.unlink(potfile) 
    7676 
     77        all_files = [] 
    7778        for (dirpath, dirnames, filenames) in os.walk("."): 
    78             for file in filenames: 
    79                 if domain == 'djangojs' and file.endswith('.js'): 
    80                     if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath)) 
     79            all_files.extend([(dirpath, f) for f in filenames]) 
     80        all_files.sort() 
     81        for dirpath, file in all_files: 
     82            if domain == 'djangojs' and file.endswith('.js'): 
     83                if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath)) 
     84                src = open(os.path.join(dirpath, file), "rb").read() 
     85                src = pythonize_re.sub('\n#', src) 
     86                open(os.path.join(dirpath, '%s.py' % file), "wb").write(src) 
     87                thefile = '%s.py' % file 
     88                cmd = 'xgettext %s -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % ( 
     89                    os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile)) 
     90                (stdin, stdout, stderr) = os.popen3(cmd, 't') 
     91                msgs = stdout.read() 
     92                errors = stderr.read() 
     93                if errors: 
     94                    print "errors happened while running xgettext on %s" % file 
     95                    print errors 
     96                    sys.exit(8) 
     97                old = '#: '+os.path.join(dirpath, thefile)[2:] 
     98                new = '#: '+os.path.join(dirpath, file)[2:] 
     99                msgs = msgs.replace(old, new) 
     100                if msgs: 
     101                    open(potfile, 'ab').write(msgs) 
     102                os.unlink(os.path.join(dirpath, thefile)) 
     103            elif domain == 'django' and (file.endswith('.py') or file.endswith('.html')): 
     104                thefile = file 
     105                if file.endswith('.html'): 
    81106                    src = open(os.path.join(dirpath, file), "rb").read() 
    82                     src = pythonize_re.sub('\n#', src) 
    83                     open(os.path.join(dirpath, '%s.py' % file), "wb").write(src) 
    84107                    thefile = '%s.py' % file 
    85                     cmd = 'xgettext %s -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % ( 
    86                         os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile)) 
    87                     (stdin, stdout, stderr) = os.popen3(cmd, 't') 
    88                     msgs = stdout.read() 
    89                     errors = stderr.read() 
    90                     if errors: 
    91                         print "errors happened while running xgettext on %s" % file 
    92                         print errors 
    93                         sys.exit(8) 
     108                    open(os.path.join(dirpath, thefile), "wb").write(templatize(src)) 
     109                if verbose: 
     110                    sys.stdout.write('processing file %s in %s\n' % (file, dirpath)) 
     111                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"' % ( 
     112                    domain, os.path.join(dirpath, thefile)) 
     113                (stdin, stdout, stderr) = os.popen3(cmd, 't') 
     114                msgs = stdout.read() 
     115                errors = stderr.read() 
     116                if errors: 
     117                    print "errors happened while running xgettext on %s" % file 
     118                    print errors 
     119                    sys.exit(8) 
     120                if thefile != file: 
    94121                    old = '#: '+os.path.join(dirpath, thefile)[2:] 
    95122                    new = '#: '+os.path.join(dirpath, file)[2:] 
    96123                    msgs = msgs.replace(old, new) 
    97                     if msgs: 
    98                         open(potfile, 'ab').write(msgs) 
     124                if os.path.exists(potfile): 
     125                    # Strip the header 
     126                    msgs = '\n'.join(dropwhile(len, msgs.split('\n'))) 
     127                else: 
     128                    msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8') 
     129                if msgs: 
     130                    open(potfile, 'ab').write(msgs) 
     131                if thefile != file: 
    99132                    os.unlink(os.path.join(dirpath, thefile)) 
    100                 elif domain == 'django' and (file.endswith('.py') or file.endswith('.html')): 
    101                     thefile = file 
    102                     if file.endswith('.html'): 
    103                         src = open(os.path.join(dirpath, file), "rb").read() 
    104                         thefile = '%s.py' % file 
    105                         open(os.path.join(dirpath, thefile), "wb").write(templatize(src)) 
    106                     if verbose: 
    107                         sys.stdout.write('processing file %s in %s\n' % (file, dirpath)) 
    108                     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"' % ( 
    109                         domain, os.path.join(dirpath, thefile)) 
    110                     (stdin, stdout, stderr) = os.popen3(cmd, 't') 
    111                     msgs = stdout.read() 
    112                     errors = stderr.read() 
    113                     if errors: 
    114                         print "errors happened while running xgettext on %s" % file 
    115                         print errors 
    116                         sys.exit(8) 
    117                     if thefile != file: 
    118                         old = '#: '+os.path.join(dirpath, thefile)[2:] 
    119                         new = '#: '+os.path.join(dirpath, file)[2:] 
    120                         msgs = msgs.replace(old, new) 
    121                     if os.path.exists(potfile): 
    122                         # Strip the header 
    123                         msgs = '\n'.join(dropwhile(len, msgs.split('\n'))) 
    124                     else: 
    125                         msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8') 
    126                     if msgs: 
    127                         open(potfile, 'ab').write(msgs) 
    128                     if thefile != file: 
    129                         os.unlink(os.path.join(dirpath, thefile)) 
    130133 
    131134        if os.path.exists(potfile): 
  • django/branches/newforms-admin/django/conf/locale/de/LC_MESSAGES/django.po

    r5918 r6459  
    1 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 
    2 # This file is distributed under the same license as the PACKAGE package. 
    3 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. 
     1# Translation of django.po to German 
     2
     3# Copyright (C) 2005-2007, 
     4# This file is distributed under the same license as the django package. 
    45# 
    56msgid "" 
     
    16301631msgstr "Webseiten" 
    16311632 
    1632 #: contrib/humanize/templatetags/humanize.py:17 
     1633#: contrib/humanize/templatetags/humanize.py:20 
    16331634msgid "th" 
    1634 msgstr "
    1635  
    1636 #: contrib/humanize/templatetags/humanize.py:17 
     1635msgstr ".
     1636 
     1637#: contrib/humanize/templatetags/humanize.py:20 
    16371638msgid "st" 
    1638 msgstr "
    1639  
    1640 #: contrib/humanize/templatetags/humanize.py:17 
     1639msgstr ".
     1640 
     1641#: contrib/humanize/templatetags/humanize.py:20 
    16411642msgid "nd" 
    1642 msgstr "
    1643  
    1644 #: contrib/humanize/templatetags/humanize.py:17 
     1643msgstr ".
     1644 
     1645#: contrib/humanize/templatetags/humanize.py:20 
    16451646msgid "rd" 
    1646 msgstr "
    1647  
    1648 #: contrib/humanize/templatetags/humanize.py:47 
     1647msgstr ".
     1648 
     1649#: contrib/humanize/templatetags/humanize.py:50 
    16491650#, python-format 
    16501651msgid "%(value).1f million" 
    16511652msgid_plural "%(value).1f million" 
    1652 msgstr[0] "
    1653 msgstr[1] "
    1654  
    1655 #: contrib/humanize/templatetags/humanize.py:50 
     1653msgstr[0] "%(value).1f Million
     1654msgstr[1] "%(value).1f Millionen
     1655 
     1656#: contrib/humanize/templatetags/humanize.py:53 
    16561657#, python-format 
    16571658msgid "%(value).1f billion" 
    16581659msgid_plural "%(value).1f billion" 
    1659 msgstr[0] "
    1660 msgstr[1] "
    1661  
    1662 #: contrib/humanize/templatetags/humanize.py:53 
     1660msgstr[0] "%(value).1f Milliarde
     1661msgstr[1] "%(value).1f Milliarden
     1662 
     1663#: contrib/humanize/templatetags/humanize.py:56 
    16631664#, python-format 
    16641665msgid "%(value).1f trillion" 
    16651666msgid_plural "%(value).1f trillion" 
    1666 msgstr[0] "
    1667 msgstr[1] "
    1668  
    1669 #: contrib/humanize/templatetags/humanize.py:68 
     1667msgstr[0] "%(value).1f Billion
     1668msgstr[1] "%(value).1f Billionen
     1669 
     1670#: contrib/humanize/templatetags/humanize.py:71 
    16701671msgid "one" 
    16711672msgstr "ein" 
    16721673 
    1673 #: contrib/humanize/templatetags/humanize.py:68 
     1674#: contrib/humanize/templatetags/humanize.py:71 
    16741675msgid "two" 
    16751676msgstr "zwei" 
    16761677 
    1677 #: contrib/humanize/templatetags/humanize.py:68 
     1678#: contrib/humanize/templatetags/humanize.py:71 
    16781679msgid "three" 
    16791680msgstr "drei" 
    16801681 
    1681 #: contrib/humanize/templatetags/humanize.py:68 
     1682#: contrib/humanize/templatetags/humanize.py:71 
    16821683msgid "four" 
    16831684msgstr "vier" 
    16841685 
    1685 #: contrib/humanize/templatetags/humanize.py:68 
     1686#: contrib/humanize/templatetags/humanize.py:71 
    16861687msgid "five" 
    16871688msgstr "fünf" 
    16881689 
    1689 #: contrib/humanize/templatetags/humanize.py:68 
     1690#: contrib/humanize/templatetags/humanize.py:71 
    16901691msgid "six" 
    16911692msgstr "sechs" 
    16921693 
    1693 #: contrib/humanize/templatetags/humanize.py:68 
     1694#: contrib/humanize/templatetags/humanize.py:71 
    16941695msgid "seven" 
    16951696msgstr "sieben" 
    16961697 
    1697 #: contrib/humanize/templatetags/humanize.py:68 
     1698#: contrib/humanize/templatetags/humanize.py:71 
    16981699msgid "eight" 
    16991700msgstr "acht" 
    17001701 
    1701 #: contrib/humanize/templatetags/humanize.py:68 
     1702#: contrib/humanize/templatetags/humanize.py:71 
    17021703msgid "nine" 
    17031704msgstr "neun" 
  • django/branches/newforms-admin/django/contrib/auth/backends.py

    r6417 r6459  
    22from django.contrib.auth.models import User 
    33 
     4try:  
     5    set  
     6except NameError:  
     7    from sets import Set as set # Python 2.3 fallback 
     8         
    49class ModelBackend: 
    510    """ 
  • django/branches/newforms-admin/django/contrib/sessions/models.py

    r6371 r6459  
    1 import base64, md5, random, sys, datetime 
     1import os 
     2import sys 
     3import time 
     4import datetime 
     5import base64 
     6import md5 
     7import random 
    28import cPickle as pickle 
     9 
    310from django.db import models 
    411from django.utils.translation import ugettext_lazy as _ 
  • django/branches/newforms-admin/django/core/handlers/wsgi.py

    r6342 r6459  
     1from threading import Lock 
     2from pprint import pformat 
     3try: 
     4    from cStringIO import StringIO 
     5except ImportError: 
     6    from StringIO import StringIO 
     7 
    18from django.core.handlers.base import BaseHandler 
    29from django.core import signals 
     
    512from django.utils.encoding import force_unicode 
    613from django import http 
    7 from pprint import pformat 
    8 from shutil import copyfileobj 
    9 from threading import Lock 
    10 try: 
    11     from cStringIO import StringIO 
    12 except ImportError: 
    13     from StringIO import StringIO 
    1414 
    1515# See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 
     
    106106 
    107107    def is_secure(self): 
    108         return 'HTTPS' in self.environ and self.environ['HTTPS'] == 'on' 
     108        return 'wsgi.url_scheme' in self.environ \ 
     109            and self.environ['wsgi.url_scheme'] == 'https' 
    109110 
    110111    def _load_post_and_files(self): 
  • django/branches/newforms-admin/django/core/management/commands/startapp.py

    r5918 r6459  
    1717        # Determine the project_name a bit naively -- by looking at the name of 
    1818        # the parent directory. 
    19         project_dir = os.path.normpath(os.path.join(directory, '..')) 
     19        project_dir = os.path.normpath(os.path.join(directory, os.pardir)) 
    2020        parent_dir = os.path.basename(project_dir) 
    2121        project_name = os.path.basename(directory) 
  • django/branches/newforms-admin/django/core/management/__init__.py

    r6417 r6459  
    240240    project_name = os.path.basename(project_directory) 
    241241    settings_name = os.path.splitext(settings_filename)[0] 
    242     sys.path.append(os.path.join(project_directory, '..')) 
     242    sys.path.append(os.path.join(project_directory, os.pardir)) 
    243243    project_module = __import__(project_name, {}, {}, ['']) 
    244244    sys.path.pop() 
  • django/branches/newforms-admin/django/db/models/fields/__init__.py

    r6417 r6459  
    237237            if callable(self.default): 
    238238                return self.default() 
    239             return self.default 
     239            return force_unicode(self.default, strings_only=True) 
    240240        if not self.empty_strings_allowed or (self.null and settings.DATABASE_ENGINE != 'oracle'): 
    241241            return None 
  • django/branches/newforms-admin/django/http/__init__.py

    r6458 r6459  
    4848        "Returns the HTTP host using the environment or request headers." 
    4949        # We try three options, in order of decreasing preference. 
    50         host = self.META.get('HTTP_X_FORWARDED_HOST', '') 
    51         if 'HTTP_HOST' in self.META: 
     50        if 'HTTP_X_FORWARDED_HOST' in self.META: 
     51            host = self.META['HTTP_X_FORWARDED_HOST'] 
     52        elif 'HTTP_HOST' in self.META: 
    5253            host = self.META['HTTP_HOST'] 
    5354        else: 
  • django/branches/newforms-admin/django/newforms/widgets.py

    r6342 r6459  
    88    from sets import Set as set   # Python 2.3 fallback 
    99 
     10import copy 
    1011from itertools import chain 
    1112from django.conf import settings 
     
    136137            self.attrs = {} 
    137138 
     139    def __deepcopy__(self, memo): 
     140        obj = copy.copy(self) 
     141        obj.attrs = self.attrs.copy() 
     142        memo[id(self)] = obj 
     143        return obj 
     144 
    138145    def render(self, name, value, attrs=None): 
    139146        """ 
     
    192199 
    193200    def __init__(self, attrs=None, render_value=True): 
    194         self.attrs = attrs or {} 
     201        super(PasswordInput, self).__init__(attrs) 
    195202        self.render_value = render_value 
    196203 
     
    209216    """ 
    210217    def __init__(self, attrs=None, choices=()): 
     218        super(MultipleHiddenInput, self).__init__(attrs) 
    211219        # choices can be any iterable 
    212         self.attrs = attrs or {} 
    213220        self.choices = choices 
    214221 
     
    249256class CheckboxInput(Widget): 
    250257    def __init__(self, attrs=None, check_test=bool): 
     258        super(CheckboxInput, self).__init__(attrs) 
    251259        # check_test is a callable that takes a value and returns True 
    252260        # if the checkbox should be checked for that value. 
    253         self.attrs = attrs or {} 
    254261        self.check_test = check_test 
    255262 
     
    268275class Select(Widget): 
    269276    def __init__(self, attrs=None, choices=()): 
    270         self.attrs = attrs or {} 
     277        super(Select, self).__init__(attrs) 
    271278        # choices can be any iterable, but we may need to render this widget 
    272279        # multiple times. Thus, collapse it into a list so it can be consumed 
     
    307314class SelectMultiple(Widget): 
    308315    def __init__(self, attrs=None, choices=()): 
     316        super(SelectMultiple, self).__init__(attrs) 
    309317        # choices can be any iterable 
    310         self.attrs = attrs or {} 
    311318        self.choices = choices 
    312319 
     
    531538            return [value.date(), value.time()] 
    532539        return [None, None] 
    533      
  • django/branches/newforms-admin/django/oldforms/__init__.py

    r6417 r6459  
    501501            if smart_unicode(value) == str_data: 
    502502                selected_html = u' selected="selected"' 
    503             output.append(u'    <option value="%s"%s>%s</option>' % (escape(value), selected_html, escape(display_name))) 
     503            output.append(u'    <option value="%s"%s>%s</option>' % (escape(value), selected_html, force_unicode(escape(display_name)))) 
    504504        output.append(u'  </select>') 
    505505        return u'\n'.join(output) 
     
    613613            if smart_unicode(value) in str_data_list: 
    614614                selected_html = u' selected="selected"' 
    615             output.append(u'    <option value="%s"%s>%s</option>' % (escape(value), selected_html, escape(choice))) 
     615            output.append(u'    <option value="%s"%s>%s</option>' % (escape(value), selected_html, force_unicode(escape(choice)))) 
    616616        output.append(u'  </select>') 
    617617        return u'\n'.join(output) 
  • django/branches/newforms-admin/django/utils/cache.py

    r6342 r6459  
    2424from django.conf import settings 
    2525from django.core.cache import cache 
    26 from django.utils.encoding import smart_str 
     26from django.utils.encoding import smart_str, iri_to_uri 
    2727 
    2828cc_delim_re = re.compile(r'\s*,\s*') 
     
    5858    else: 
    5959        cc = {} 
     60 
     61    # If there's already a max-age header but we're being asked to set a new 
     62    # max-age, use the minumum of the two ages. In practice this happens when 
     63    # a decorator and a piece of middleware both operate on a given view. 
     64    if 'max-age' in cc and 'max_age' in kwargs: 
     65        kwargs['max_age'] = min(cc['max-age'], kwargs['max_age']) 
     66 
    6067    for (k,v) in kwargs.items(): 
    6168        cc[k.replace('_', '-')] = v 
     
    119126        if value is not None: 
    120127            ctx.update(value) 
    121     return 'views.decorators.cache.cache_page.%s.%s.%s' % (key_prefix, request.path, ctx.hexdigest()) 
     128    return 'views.decorators.cache.cache_page.%s.%s.%s' % (key_prefix, iri_to_uri(request.path), ctx.hexdigest()) 
    122129 
    123130def get_cache_key(request, key_prefix=None): 
     
    133140    if key_prefix is None: 
    134141        key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX 
    135     cache_key = 'views.decorators.cache.cache_header.%s.%s' % (key_prefix, request.path
     142    cache_key = 'views.decorators.cache.cache_header.%s.%s' % (key_prefix, iri_to_uri(request.path)
    136143    headerlist = cache.get(cache_key, None) 
    137144    if headerlist is not None: 
     
    157164    if cache_timeout is None: 
    158165        cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS 
    159     cache_key = 'views.decorators.cache.cache_header.%s.%s' % (key_prefix, request.path
     166    cache_key = 'views.decorators.cache.cache_header.%s.%s' % (key_prefix, iri_to_uri(request.path)
    160167    if response.has_header('Vary'): 
    161168        headerlist = ['HTTP_'+header.upper().replace('-', '_') for header in vary_delim_re.split(response['Vary'])] 
  • django/branches/newforms-admin/django/utils/translation/__init__.py

    r5627 r6459  
    33""" 
    44from django.utils.functional import lazy 
     5from django.utils.encoding import force_unicode 
    56 
    67__all__ = ['gettext', 'gettext_noop', 'gettext_lazy', 'ngettext', 
     
    4041 
    4142    # Make the originally requested function call on the way out the door. 
    42     return g[caller](*args, **kwargs) 
     43    return g['real_%s' % caller](*args, **kwargs) 
    4344 
    4445g = globals() 
     
    6465    return real_ungettext(singular, plural, number) 
    6566 
    66 def string_concat(*strings): 
    67     return real_string_concat(*strings) 
    68  
    6967ngettext_lazy = lazy(ngettext, str) 
    7068gettext_lazy = lazy(gettext, str) 
    7169ungettext_lazy = lazy(ungettext, unicode) 
    7270ugettext_lazy = lazy(ugettext, unicode) 
    73 string_concat = lazy(string_concat, unicode) 
    7471 
    7572def activate(language): 
     
    109106    return real_deactivate_all() 
    110107 
     108def string_concat(*strings): 
     109    """ 
     110    Lazy variant of string concatenation, needed for translations that are 
     111    constructed from multiple parts. 
     112    """ 
     113    return u''.join([force_unicode(s) for s in strings]) 
     114string_concat = lazy(string_concat, unicode) 
  • django/branches/newforms-admin/django/utils/translation/trans_null.py

    r5627 r6459  
    1414    return force_unicode(ngettext(singular, plural, number)) 
    1515 
    16 string_concat = lambda *strings: u''.join([force_unicode(el) for el in strings]) 
    1716activate = lambda x: None 
    1817deactivate = deactivate_all = install = lambda: None 
  • django/branches/newforms-admin/django/utils/translation/trans_real.py

    r6342 r6459  
    517517    return out.getvalue() 
    518518 
    519 def string_concat(*strings): 
    520     """" 
    521     Lazy variant of string concatenation, needed for translations that are 
    522     constructed from multiple parts. 
    523     """ 
    524     return u''.join([force_unicode(s) for s in strings]) 
  • django/branches/newforms-admin/django/views/static.py

    r4265 r6459  
    3030    for part in path.split('/'): 
    3131        if not part: 
    32             # strip empty path components 
     32            # Strip empty path components. 
    3333            continue 
    3434        drive, part = os.path.splitdrive(part) 
    3535        head, part = os.path.split(part) 
    3636        if part in (os.curdir, os.pardir): 
    37             # strip '.' amd '..' in path 
     37            # Strip '.' and '..' in path. 
    3838            continue 
    3939        newpath = os.path.join(newpath, part).replace('\\', '/') 
  • django/branches/newforms-admin/docs/databases.txt

    r6342 r6459  
    164164.. _AlterModelOnSyncDB: http://code.djangoproject.com/wiki/AlterModelOnSyncDB 
    165165 
     166 
     167Oracle Notes 
     168============ 
     169 
     170Django supports `Oracle Database Server`_ versions 9i and higher.  Oracle 
     171version 10g or later is required to use Django's ``regex`` and ``iregex`` query 
     172operators.  You will also need the `cx_Oracle`_ driver, version 4.3.1 or newer. 
     173 
     174.. _`Oracle Database Server`: http://www.oracle.com/ 
     175.. _`cx_Oracle`: http://cx-oracle.sourceforge.net/ 
     176 
     177To run ``python manage.py syncdb``, you'll need to create an Oracle database 
     178user with CREATE TABLE, CREATE SEQUENCE, CREATE PROCEDURE, and CREATE TRIGGER 
     179privileges.  To run Django's test suite, the user also needs  
     180CREATE and DROP DATABASE and CREATE and DROP TABLESPACE privileges. 
     181 
     182Connecting to the Database 
     183-------------------------- 
     184 
     185Your Django settings.py file should look something like this for Oracle:: 
     186 
     187    DATABASE_ENGINE = 'oracle' 
     188    DATABASE_NAME = 'xe' 
     189    DATABASE_USER = 'a_user' 
     190    DATABASE_PASSWORD = 'a_password' 
     191    DATABASE_HOST = '' 
     192    DATABASE_PORT = '' 
     193 
     194If you don't use a ``tnsnames.ora`` file or a similar naming method that 
     195recognizes the SID ("xe" in this example), then fill in both ``DATABASE_HOST`` 
     196and ``DATABASE_PORT`` like so:: 
     197 
     198    DATABASE_ENGINE = 'oracle' 
     199    DATABASE_NAME = 'xe' 
     200    DATABASE_USER = 'a_user' 
     201    DATABASE_PASSWORD = 'a_password' 
     202    DATABASE_HOST = 'dbprod01ned.mycompany.com' 
     203    DATABASE_PORT = '1540' 
     204 
     205You should supply both ``DATABASE_HOST`` and ``DATABASE_PORT``, or leave both 
     206as empty strings. 
     207 
     208Tablespace Options 
     209------------------ 
     210 
     211A common paradigm for optimizing performance in Oracle-based systems is the 
     212use of `tablespaces`_ to organize disk layout. The Oracle backend supports 
     213this use case by adding ``db_tablespace`` options to the ``Meta`` and 
     214``Field`` classes.  (When using a backend that lacks support for tablespaces, 
     215these options are ignored.) 
     216 
     217.. _`tablespaces`: http://en.wikipedia.org/wiki/Tablespace 
     218 
     219A tablespace can be specified for the table(s) generated by a model by 
     220supplying the ``db_tablespace`` option inside the model's ``Meta`` class. 
     221Additionally, the ``db_tablespace`` option can be passed to a ``Field`` 
     222constructor to specify an alternate tablespace for the ``Field``'s column 
     223index.  If no index would be created for the column, the ``db_tablespace`` 
     224option is ignored. 
     225 
     226:: 
     227 
     228    class TablespaceExample(models.Model): 
     229        name = models.CharField(maxlength=30, db_index=True, db_tablespace="indexes") 
     230        data = models.CharField(maxlength=255, db_index=True) 
     231        edges = models.ManyToManyField(to="self", db_tablespace="indexes") 
     232 
     233        class Meta: 
     234            db_tablespace = "tables" 
     235 
     236In this example, the tables generated by the ``TablespaceExample`` model 
     237(i.e., the model table and the many-to-many table) would be stored in the 
     238``tables`` tablespace.  The index for the name field and the indexes on the 
     239many-to-many table would be stored in the ``indexes`` tablespace.  The ``data`` 
     240field would also generate an index, but no tablespace for it is specified, so 
     241it would be stored in the model tablespace ``tables`` by default. 
     242 
     243Django does not create the tablespaces for you.  Please refer to `Oracle's 
     244documentation`_ for details on creating and managing tablespaces. 
     245 
     246.. _`Oracle's documentation`: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7003.htm#SQLRF01403 
     247 
     248Naming Issues 
     249------------- 
     250 
     251Oracle imposes a name length limit of 30 characters.  To accommodate this, the 
     252backend truncates database identifiers to fit, replacing the final four 
     253characters of the truncated name with a repeatable MD5 hash value. 
     254 
     255NULL and Empty Strings 
     256---------------------- 
     257 
     258Django generally prefers to use the empty string ('') rather than NULL, but 
     259Oracle treats both identically.  To get around this, the Oracle backend 
     260coerces the ``null=True`` option on fields that permit the empty string as a 
     261value.  When fetching from the database, it is assumed that a NULL value in 
     262one of these fields really means the empty string, and the data is silently 
     263converted to reflect this assumption. 
     264 
     265TextField Limitations 
     266--------------------- 
     267 
     268The Oracle backend stores ``TextFields`` as ``NCLOB`` columns.  Oracle imposes 
     269some limitations on the usage of such LOB columns in general: 
     270 
     271  * LOB columns may not be used as primary keys. 
     272 
     273  * LOB columns may not be used in indexes. 
     274 
     275  * LOB columns may not be used in a ``SELECT DISTINCT`` list.  This means that 
     276    attempting to use the ``QuerySet.distinct`` method on a model that 
     277    includes ``TextField`` columns will result in an error when run against 
     278    Oracle.  A workaround to this is to keep ``TextField`` columns out of any 
     279    models that you foresee performing ``.distinct`` queries on, and to 
     280    include the ``TextField`` in a related model instead. 
  • django/branches/newforms-admin/docs/email.txt

    r6417 r6459  
    318318    text_content = 'This is an important message.' 
    319319    html_content = '<p>This is an <strong>important</strong> message.</p>' 
    320     msg = EmailMultiAlternatives(subject, text_content, from_email, to
     320    msg = EmailMultiAlternatives(subject, text_content, from_email, [to]
    321321    msg.attach_alternative(html_content, "text/html") 
    322322    msg.send() 
  • django/branches/newforms-admin/docs/install.txt

    r6371 r6459  
    6767 
    6868* If you're using Oracle, you'll need cx_Oracle_, version 4.3.1 or higher. 
     69  You will also want to read the database-specific notes for the `Oracle backend`_. 
    6970 
    7071If you plan to use Django's ``manage.py syncdb`` command to 
     
    8990.. _cx_Oracle: http://cx-oracle.sourceforge.net/ 
    9091.. _Oracle: http://www.oracle.com/ 
     92.. _Oracle backend: ../databases/#oracle-notes 
    9193.. _testing framework: ../testing/ 
    9294 
  • django/branches/newforms-admin/docs/newforms.txt

    r6417 r6459  
    23892389 
    23902390That's all the documentation for now. For more, see the file 
    2391 http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py 
     2391http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms 
    23922392-- the unit tests for ``django.newforms``. This can give you a good idea of 
    2393 what's possible. 
     2393what's possible. (Each submodule there contains separate tests.) 
    23942394 
    23952395If you're really itching to learn and use this library, please be patient. 
  • django/branches/newforms-admin/tests/modeltests/basic/models.py

    r6371 r6459  
    153153>>> a6.save() 
    154154>>> a6.headline 
    155 'Default headline' 
     155u'Default headline' 
    156156 
    157157# For DateTimeFields, Django saves as much precision (in seconds) as you 
  • django/branches/newforms-admin/tests/modeltests/field_defaults/models.py

    r5918 r6459  
    4343# Access database columns via Python attributes. 
    4444>>> a.headline 
    45 'Default headline' 
     45u'Default headline' 
    4646 
    4747# make sure the two dates are sufficiently close 
  • django/branches/newforms-admin/tests/regressiontests/i18n/models.py

    r5918 r6459  
     1from django.db import models 
     2from django.utils.translation import ugettext_lazy as _ 
     3 
     4class TestModel(models.Model): 
     5    text = models.CharField(max_length=10, default=_('Anything')) 
     6 
     7__test__ = {'API_TESTS': ''' 
     8>>> tm = TestModel() 
     9>>> tm.save() 
     10''' 
     11} 
     12 
  • django/branches/newforms-admin/tests/regressiontests/i18n/tests.py

    r5918 r6459  
    3131>>> s == s4 
    3232False 
     33 
     34unicode(string_concat(...)) should not raise a TypeError - #4796 
     35