Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

unicode: Merged from trunk up to [5265].

git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5279 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 60424589264285e3127f892ab6bfc38de2c0e4a8 1 parent c0b451f
Malcolm Tredinnick authored May 17, 2007
8  django/core/management.py
@@ -578,7 +578,7 @@ def syncdb(verbosity=1, interactive=True):
578 578
     # Install the 'initialdata' fixture, using format discovery
579 579
     load_data(['initial_data'], verbosity=verbosity)
580 580
 syncdb.help_doc = "Create the database tables for all apps in INSTALLED_APPS whose tables haven't already been created."
581  
-syncdb.args = '[--verbosity] [--interactive]'
  581
+syncdb.args = '[--verbosity] [--noinput]'
582 582
 
583 583
 def get_admin_index(app):
584 584
     "Returns admin-index template snippet (in list form) for the given app."
@@ -672,7 +672,7 @@ def reset(app, interactive=True):
672 672
     else:
673 673
         print "Reset cancelled."
674 674
 reset.help_doc = "Executes ``sqlreset`` for the given app(s) in the current database."
675  
-reset.args = '[--interactive]' + APP_ARGS
  675
+reset.args = '[--noinput]' + APP_ARGS
676 676
 
677 677
 def flush(verbosity=1, interactive=True):
678 678
     "Returns all tables in the database to the same state they were in immediately after syncdb."
@@ -733,7 +733,7 @@ def flush(verbosity=1, interactive=True):
733 733
     else:
734 734
         print "Flush cancelled."
735 735
 flush.help_doc = "Executes ``sqlflush`` on the current database."
736  
-flush.args = '[--verbosity] [--interactive]'
  736
+flush.args = '[--verbosity] [--noinput]'
737 737
 
738 738
 def _start_helper(app_or_project, name, directory, other_name=''):
739 739
     other = {'project': 'app', 'app': 'project'}[app_or_project]
@@ -1452,7 +1452,7 @@ def dump_data(app_labels, format='json', indent=None):
1452 1452
     except Exception, e:
1453 1453
         sys.stderr.write(style.ERROR("Unable to serialize database: %s\n" % e))
1454 1454
 dump_data.help_doc = 'Output the contents of the database as a fixture of the given format'
1455  
-dump_data.args = '[--format]' + APP_ARGS
  1455
+dump_data.args = '[--format] [--indent]' + APP_ARGS
1456 1456
 
1457 1457
 # Utilities for command-line script
1458 1458
 
3  django/newforms/extras/widgets.py
@@ -2,9 +2,10 @@
2 2
 Extra HTML Widget classes
3 3
 """
4 4
 
  5
+import datetime
  6
+
5 7
 from django.newforms.widgets import Widget, Select
6 8
 from django.utils.dates import MONTHS
7  
-import datetime
8 9
 
9 10
 __all__ = ('SelectDateWidget',)
10 11
 
8  django/newforms/fields.py
@@ -2,13 +2,15 @@
2 2
 Field classes
3 3
 """
4 4
 
  5
+import datetime
  6
+import re
  7
+import time
  8
+
5 9
 from django.utils.translation import ugettext
6 10
 from django.utils.encoding import smart_unicode
  11
+
7 12
 from util import ErrorList, ValidationError
8 13
 from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple
9  
-import datetime
10  
-import re
11  
-import time
12 14
 
13 15
 __all__ = (
14 16
     'Field', 'CharField', 'IntegerField',
8  django/newforms/forms.py
@@ -2,13 +2,15 @@
2 2
 Form classes
3 3
 """
4 4
 
5  
-from django.utils.datastructures import SortedDict, MultiValueDict
  5
+import copy
  6
+
  7
+from django.utils.datastructures import SortedDict
6 8
 from django.utils.html import escape
7 9
 from django.utils.encoding import StrAndUnicode, smart_unicode
  10
+
8 11
 from fields import Field
9  
-from widgets import TextInput, Textarea, HiddenInput, MultipleHiddenInput
  12
+from widgets import TextInput, Textarea
10 13
 from util import flatatt, ErrorDict, ErrorList, ValidationError
11  
-import copy
12 14
 
13 15
 __all__ = ('BaseForm', 'Form')
14 16
 
9  django/newforms/models.py
@@ -5,13 +5,16 @@
5 5
 
6 6
 from django.utils.translation import ugettext
7 7
 from django.utils.encoding import smart_unicode
  8
+
8 9
 from util import ValidationError
9  
-from forms import BaseForm, DeclarativeFieldsMetaclass, SortedDictFromList
  10
+from forms import BaseForm, SortedDictFromList
10 11
 from fields import Field, ChoiceField
11 12
 from widgets import Select, SelectMultiple, MultipleHiddenInput
12 13
 
13  
-__all__ = ('save_instance', 'form_for_model', 'form_for_instance', 'form_for_fields',
14  
-           'ModelChoiceField', 'ModelMultipleChoiceField')
  14
+__all__ = (
  15
+    'save_instance', 'form_for_model', 'form_for_instance', 'form_for_fields',
  16
+    'ModelChoiceField', 'ModelMultipleChoiceField'
  17
+)
15 18
 
16 19
 def save_instance(form, instance, fields=None, fail_message='saved', commit=True):
17 20
     """
2  django/newforms/util.py
... ...
@@ -1,6 +1,4 @@
1  
-from django.conf import settings
2 1
 from django.utils.html import escape
3  
-from django.utils.functional import Promise, lazy
4 2
 from django.utils.encoding import smart_unicode
5 3
 
6 4
 # Converts a dictionary to a single string with key="value", XML-style with
26  django/newforms/widgets.py
@@ -2,24 +2,26 @@
2 2
 HTML Widget classes
3 3
 """
4 4
 
5  
-__all__ = (
6  
-    'Widget', 'TextInput', 'PasswordInput', 'HiddenInput', 'MultipleHiddenInput',
7  
-    'FileInput', 'Textarea', 'CheckboxInput',
8  
-    'Select', 'NullBooleanSelect', 'SelectMultiple', 'RadioSelect', 'CheckboxSelectMultiple',
9  
-    'MultiWidget', 'SplitDateTimeWidget',
10  
-)
  5
+try:
  6
+    set # Only available in Python 2.4+
  7
+except NameError:
  8
+    from sets import Set as set # Python 2.3 fallback
  9
+from itertools import chain
11 10
 
12  
-from util import flatatt
13 11
 from django.utils.datastructures import MultiValueDict
14 12
 from django.utils.html import escape
15 13
 from django.utils.translation import ugettext
16 14
 from django.utils.encoding import StrAndUnicode, smart_unicode
17  
-from itertools import chain
18 15
 
19  
-try:
20  
-    set # Only available in Python 2.4+
21  
-except NameError:
22  
-    from sets import Set as set # Python 2.3 fallback
  16
+from util import flatatt
  17
+
  18
+__all__ = (
  19
+    'Widget', 'TextInput', 'PasswordInput',
  20
+    'HiddenInput', 'MultipleHiddenInput',
  21
+    'FileInput', 'Textarea', 'CheckboxInput',
  22
+    'Select', 'NullBooleanSelect', 'SelectMultiple', 'RadioSelect',
  23
+    'CheckboxSelectMultiple', 'MultiWidget', 'SplitDateTimeWidget',
  24
+)
23 25
 
24 26
 class Widget(object):
25 27
     is_hidden = False          # Determines whether this corresponds to an <input type="hidden">.
83  docs/contributing.txt
@@ -279,6 +279,15 @@ Please follow these coding standards when writing code for inclusion in Django:
279 279
     * Mark all strings for internationalization; see the `i18n documentation`_
280 280
       for details.
281 281
 
  282
+    * Please don't put your name in the code you contribute. Our policy is to
  283
+      keep contributors' names in the ``AUTHORS`` file distributed with Django
  284
+      -- not scattered throughout the codebase itself. Feel free to include a
  285
+      change to the ``AUTHORS`` file in your patch if you make more than a
  286
+      single trivial change.
  287
+
  288
+Template style
  289
+--------------
  290
+
282 291
     * In Django template code, put one (and only one) space between the curly
283 292
       brackets and the tag contents.
284 293
 
@@ -290,6 +299,9 @@ Please follow these coding standards when writing code for inclusion in Django:
290 299
 
291 300
           {{foo}}
292 301
 
  302
+View style
  303
+----------
  304
+
293 305
     * In Django views, the first parameter in a view function should be called
294 306
       ``request``.
295 307
 
@@ -303,11 +315,72 @@ Please follow these coding standards when writing code for inclusion in Django:
303 315
           def my_view(req, foo):
304 316
               # ...
305 317
 
306  
-    * Please don't put your name in the code you contribute. Our policy is to
307  
-      keep contributors' names in the ``AUTHORS`` file distributed with Django
308  
-      -- not scattered throughout the codebase itself. Feel free to include a
309  
-      change to the ``AUTHORS`` file in your patch if you make more than a
310  
-      single trivial change.
  318
+Model style
  319
+-----------
  320
+
  321
+    * Field names should be all lowercase, using underscores instead of
  322
+      camelCase.
  323
+
  324
+      Do this::
  325
+
  326
+          class Person(models.Model):
  327
+              first_name = models.CharField(maxlength=20)
  328
+              last_name = models.CharField(maxlength=40)
  329
+
  330
+      Don't do this::
  331
+
  332
+          class Person(models.Model):
  333
+              FirstName = models.CharField(maxlength=20)
  334
+              Last_Name = models.CharField(maxlength=40)
  335
+
  336
+    * The ``class Meta`` should appear *after* the fields are defined, with
  337
+      a single blank line separating the fields and the class definition.
  338
+
  339
+      Do this::
  340
+
  341
+          class Person(models.Model):
  342
+              first_name = models.CharField(maxlength=20)
  343
+              last_name = models.CharField(maxlength=40)
  344
+
  345
+              class Meta:
  346
+                  verbose_name_plural = 'people'
  347
+
  348
+      Don't do this::
  349
+
  350
+          class Person(models.Model):
  351
+              first_name = models.CharField(maxlength=20)
  352
+              last_name = models.CharField(maxlength=40)
  353
+              class Meta:
  354
+                  verbose_name_plural = 'people'
  355
+
  356
+      Don't do this, either::
  357
+
  358
+          class Person(models.Model):
  359
+              class Meta:
  360
+                  verbose_name_plural = 'people'
  361
+
  362
+              first_name = models.CharField(maxlength=20)
  363
+              last_name = models.CharField(maxlength=40)
  364
+
  365
+    * The order of model inner classes and standard methods should be as
  366
+      follows (noting that these are not all required):
  367
+
  368
+        * All database fields
  369
+        * ``class Meta``
  370
+        * ``class Admin``
  371
+        * ``def __str__()``
  372
+        * ``def save()``
  373
+        * ``def get_absolute_url()``
  374
+        * Any custom methods
  375
+
  376
+    * If ``choices`` is defined for a given model field, define the choices as
  377
+      a tuple of tuples, with an all-uppercase name, either near the top of the
  378
+      model module or just above the model class. Example::
  379
+
  380
+          GENDER_CHOICES = (
  381
+              ('M', 'Male'),
  382
+              ('F', 'Female'),
  383
+          )
311 384
 
312 385
 Committing code
313 386
 ===============
50  docs/db-api.txt
@@ -143,8 +143,8 @@ or ``UPDATE`` SQL statements. Specifically, when you call ``save()``, Django
143 143
 follows this algorithm:
144 144
 
145 145
     * If the object's primary key attribute is set to a value that evaluates to
146  
-      ``True`` (i.e., a value other than ``None`` or the empty string), Django 
147  
-      executes a ``SELECT`` query to determine whether a record with the given 
  146
+      ``True`` (i.e., a value other than ``None`` or the empty string), Django
  147
+      executes a ``SELECT`` query to determine whether a record with the given
148 148
       primary key already exists.
149 149
     * If the record with the given primary key does already exist, Django
150 150
       executes an ``UPDATE`` query.
@@ -525,19 +525,19 @@ Examples::
525 525
     [datetime.datetime(2005, 3, 20), datetime.datetime(2005, 2, 20)]
526 526
     >>> Entry.objects.filter(headline__contains='Lennon').dates('pub_date', 'day')
527 527
     [datetime.datetime(2005, 3, 20)]
528  
-    
  528
+
529 529
 ``none()``
530 530
 ~~~~~~~~~~
531 531
 
532 532
 **New in Django development version**
533 533
 
534  
-Returns an ``EmptyQuerySet`` -- a ``QuerySet`` that always evaluates to 
  534
+Returns an ``EmptyQuerySet`` -- a ``QuerySet`` that always evaluates to
535 535
 an empty list. This can be used in cases where you know that you should
536 536
 return an empty result set and your caller is expecting a ``QuerySet``
537 537
 object (instead of returning an empty list, for example.)
538 538
 
539 539
 Examples::
540  
-    
  540
+
541 541
     >>> Entry.objects.none()
542 542
     []
543 543
 
@@ -610,7 +610,7 @@ follow::
610 610
     c = p.hometown       # Requires a database call.
611 611
 
612 612
 The ``depth`` argument is new in the Django development version.
613  
-    
  613
+
614 614
 ``extra(select=None, where=None, params=None, tables=None)``
615 615
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
616 616
 
@@ -1136,7 +1136,7 @@ such as January 3, July 3, etc.
1136 1136
 isnull
1137 1137
 ~~~~~~
1138 1138
 
1139  
-Takes either ``True`` or ``False``, which correspond to SQL queries of 
  1139
+Takes either ``True`` or ``False``, which correspond to SQL queries of
1140 1140
 ``IS NULL`` and ``IS NOT NULL``, respectively.
1141 1141
 
1142 1142
 Example::
@@ -1149,10 +1149,10 @@ SQL equivalent::
1149 1149
 
1150 1150
 .. admonition:: ``__isnull=True`` vs ``__exact=None``
1151 1151
 
1152  
-    There is an important difference between ``__isnull=True`` and 
  1152
+    There is an important difference between ``__isnull=True`` and
1153 1153
     ``__exact=None``. ``__exact=None`` will *always* return an empty result
1154  
-    set, because SQL requires that no value is equal to ``NULL``. 
1155  
-    ``__isnull`` determines if the field is currently holding the value 
  1154
+    set, because SQL requires that no value is equal to ``NULL``.
  1155
+    ``__isnull`` determines if the field is currently holding the value
1156 1156
     of ``NULL`` without performing a comparison.
1157 1157
 
1158 1158
 search
@@ -1181,7 +1181,7 @@ The pk lookup shortcut
1181 1181
 ----------------------
1182 1182
 
1183 1183
 For convenience, Django provides a ``pk`` lookup type, which stands for
1184  
-"primary_key". 
  1184
+"primary_key".
1185 1185
 
1186 1186
 In the example ``Blog`` model, the primary key is the ``id`` field, so these
1187 1187
 three statements are equivalent::
@@ -1190,14 +1190,14 @@ three statements are equivalent::
1190 1190
     Blog.objects.get(id=14) # __exact is implied
1191 1191
     Blog.objects.get(pk=14) # pk implies id__exact
1192 1192
 
1193  
-The use of ``pk`` isn't limited to ``__exact`` queries -- any query term 
  1193
+The use of ``pk`` isn't limited to ``__exact`` queries -- any query term
1194 1194
 can be combined with ``pk`` to perform a query on the primary key of a model::
1195 1195
 
1196 1196
     # Get blogs entries  with id 1, 4 and 7
1197 1197
     Blog.objects.filter(pk__in=[1,4,7])
1198 1198
     # Get all blog entries with id > 14
1199  
-    Blog.objects.filter(pk__gt=14) 
1200  
-    
  1199
+    Blog.objects.filter(pk__gt=14)
  1200
+
1201 1201
 ``pk`` lookups also work across joins. For example, these three statements are
1202 1202
 equivalent::
1203 1203
 
@@ -1754,19 +1754,19 @@ get_object_or_404()
1754 1754
 -------------------
1755 1755
 
1756 1756
 One common idiom to use ``get()`` and raise ``Http404`` if the
1757  
-object doesn't exist. This idiom is captured by ``get_object_or_404()``. 
1758  
-This function takes a Django model as its first argument and an 
1759  
-arbitrary number of keyword arguments, which it passes to the manager's 
  1757
+object doesn't exist. This idiom is captured by ``get_object_or_404()``.
  1758
+This function takes a Django model as its first argument and an
  1759
+arbitrary number of keyword arguments, which it passes to the manager's
1760 1760
 ``get()`` function. It raises ``Http404`` if the object doesn't
1761  
-exist. For example:: 
1762  
-    
  1761
+exist. For example::
  1762
+
1763 1763
     # Get the Entry with a primary key of 3
1764 1764
     e = get_object_or_404(Entry, pk=3)
1765 1765
 
1766  
-When you provide a model to this shortcut function, the default manager 
1767  
-is used to execute the underlying ``get()`` query. If you don't want to 
1768  
-use the default manager, or you want to search a list of related objects, 
1769  
-you can provide ``get_object_or_404()`` with a manager object, instead. 
  1766
+When you provide a model to this shortcut function, the default manager
  1767
+is used to execute the underlying ``get()`` query. If you don't want to
  1768
+use the default manager, or if you want to search a list of related objects,
  1769
+you can provide ``get_object_or_404()`` with a manager object instead.
1770 1770
 For example::
1771 1771
 
1772 1772
     # Get the author of blog instance `e` with a name of 'Fred'
@@ -1779,8 +1779,8 @@ For example::
1779 1779
 get_list_or_404()
1780 1780
 -----------------
1781 1781
 
1782  
-``get_list_or_404`` behaves the same was as ``get_object_or_404()`` 
1783  
--- except the it uses using ``filter()`` instead of ``get()``. It raises 
  1782
+``get_list_or_404`` behaves the same way as ``get_object_or_404()``
  1783
+-- except that it uses ``filter()`` instead of ``get()``. It raises
1784 1784
 ``Http404`` if the list is empty.
1785 1785
 
1786 1786
 Falling back to raw SQL
9  docs/model-api.txt
@@ -1759,6 +1759,15 @@ But this template code is good::
1759 1759
 
1760 1760
     <a href="{{ object.get_absolute_url }}">{{ object.name }}</a>
1761 1761
 
  1762
+.. note::
  1763
+    The string you return from ``get_absolute_url()`` must be use only ASCII
  1764
+    characters (required by the URI spec, `RFC 2396`_) that has been
  1765
+    URL-encoded, if necessary. Code and templates using ``get_absolute_url()``
  1766
+    should be able to use the result directly without needing to do any
  1767
+    further processing.
  1768
+
  1769
+.. _RFC 2396: http://www.ietf.org/rfc/rfc2396.txt
  1770
+
1762 1771
 The ``permalink`` decorator
1763 1772
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
1764 1773
 
5  docs/syndication_feeds.txt
@@ -146,7 +146,10 @@ put into those elements.
146 146
       exist, it tries calling a method ``item_link()`` in the ``Feed`` class,
147 147
       passing it a single parameter, ``item``, which is the object itself.
148 148
       Both ``get_absolute_url()`` and ``item_link()`` should return the item's
149  
-      URL as a normal Python string.
  149
+      URL as a normal Python string. As with ``get_absolute_url()``, the
  150
+      result of ``item_link()`` will be included directly in the URL, so you
  151
+      are responsible for doing all necessary URL quoting and conversion to
  152
+      ASCII inside the method itself.
150 153
 
151 154
     * For the LatestEntries example above, we could have very simple feed templates:
152 155
 
60  extras/django_bash_completion
@@ -42,13 +42,13 @@ _django_completion()
42 42
     prev="${COMP_WORDS[COMP_CWORD-1]}"
43 43
 
44 44
     # Standalone options
45  
-    opts="--help --settings --pythonpath --version"
  45
+    opts="--help --settings --pythonpath --noinput --noreload --format --indent --verbosity --adminmedia --version"
46 46
     # Actions
47 47
     actions="adminindex createcachetable dbshell diffsettings \
48  
-             inspectdb install reset runfcgi runserver \
49  
-             shell sql sqlall sqlclear sqlindexes sqlinitialdata \
  48
+             dumpdata flush inspectdb loaddata reset runfcgi runserver \
  49
+             shell sql sqlall sqlclear sqlcustom sqlflush sqlindexes \
50 50
              sqlreset sqlsequencereset startapp startproject \
51  
-             syncdb validate"
  51
+             syncdb test validate"
52 52
     # Action's options
53 53
     action_shell_opts="--plain"
54 54
     action_runfcgi_opts="host port socket method maxspare minspare maxchildren daemonize pidfile workdir"
@@ -84,33 +84,33 @@ _django_completion()
84 84
         esac
85 85
     else
86 86
         case ${prev} in
87  
-            adminindex|install|reset| \
88  
-            sql|sqlall|sqlclear|sqlindexes| \
89  
-            sqlinitialdata|sqlreset|sqlsequencereset)
90  
-            # App completion
91  
-            settings=""
92  
-            # If settings.py in the PWD, use that
93  
-            if [ -e settings.py ] ; then
94  
-                settings="$PWD/settings.py"
95  
-            else
96  
-                # Use the ENV variable if it is set
97  
-                if [ $DJANGO_SETTINGS_MODULE ] ; then
98  
-                    settings=$DJANGO_SETTINGS_MODULE
  87
+            adminindex|dumpdata|reset| \
  88
+            sql|sqlall|sqlclear|sqlcustom|sqlindexes| \
  89
+            sqlreset|sqlsequencereset|test)
  90
+                # App completion
  91
+                settings=""
  92
+                # If settings.py in the PWD, use that
  93
+                if [ -e settings.py ] ; then
  94
+                    settings="$PWD/settings.py"
  95
+                else
  96
+                    # Use the ENV variable if it is set
  97
+                    if [ $DJANGO_SETTINGS_MODULE ] ; then
  98
+                        settings=$DJANGO_SETTINGS_MODULE
  99
+                    fi
99 100
                 fi
100  
-            fi
101  
-            # Couldn't find settings so return nothing
102  
-            if [ -z $settings ] ; then
103  
-                COMPREPLY=()
104  
-            # Otherwise inspect settings.py file
105  
-            else
106  
-                apps=`sed -n "/INSTALLED_APPS = (/,/)/p" $settings | \
107  
-                      grep -v "django.contrib" | 
108  
-                      sed -n "s/^[ ]*'\(.*\.\)*\(.*\)'.*$/\2 /pg" | \
109  
-                      tr -d "\n"`
110  
-                COMPREPLY=( $(compgen -W "${apps}" -- ${cur}) )
111  
-            fi
112  
-            return 0
113  
-            ;;
  101
+                # Couldn't find settings so return nothing
  102
+                if [ -z $settings ] ; then
  103
+                    COMPREPLY=()
  104
+                # Otherwise inspect settings.py file
  105
+                else
  106
+                    apps=`sed -n "/INSTALLED_APPS = (/,/)/p" $settings | \
  107
+                          grep -v "django.contrib" | 
  108
+                          sed -n "s/^[ ]*'\(.*\.\)*\(.*\)'.*$/\2 /pg" | \
  109
+                          tr -d "\n"`
  110
+                    COMPREPLY=( $(compgen -W "${apps}" -- ${cur}) )
  111
+                fi
  112
+                return 0
  113
+                ;;
114 114
 
115 115
             createcachetable|dbshell|diffsettings| \
116 116
             inspectdb|runserver|startapp|startproject|syncdb| \

0 notes on commit 6042458

Please sign in to comment.
Something went wrong with that request. Please try again.