Django

Code

Changeset 5279

Show
Ignore:
Timestamp:
05/17/07 13:35:22 (2 years ago)
Author:
mtredinnick
Message:

unicode: Merged from trunk up to [5265].

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/unicode

    • Property svnmerge-integrated changed from /django/trunk:1-5240 to /django/trunk:1-5278
  • django/branches/unicode/django/core/management.py

    r5241 r5279  
    579579    load_data(['initial_data'], verbosity=verbosity) 
    580580syncdb.help_doc = "Create the database tables for all apps in INSTALLED_APPS whose tables haven't already been created." 
    581 syncdb.args = '[--verbosity] [--interactive]' 
     581syncdb.args = '[--verbosity] [--noinput]' 
    582582 
    583583def get_admin_index(app): 
     
    673673        print "Reset cancelled." 
    674674reset.help_doc = "Executes ``sqlreset`` for the given app(s) in the current database." 
    675 reset.args = '[--interactive]' + APP_ARGS 
     675reset.args = '[--noinput]' + APP_ARGS 
    676676 
    677677def flush(verbosity=1, interactive=True): 
     
    734734        print "Flush cancelled." 
    735735flush.help_doc = "Executes ``sqlflush`` on the current database." 
    736 flush.args = '[--verbosity] [--interactive]' 
     736flush.args = '[--verbosity] [--noinput]' 
    737737 
    738738def _start_helper(app_or_project, name, directory, other_name=''): 
     
    14531453        sys.stderr.write(style.ERROR("Unable to serialize database: %s\n" % e)) 
    14541454dump_data.help_doc = 'Output the contents of the database as a fixture of the given format' 
    1455 dump_data.args = '[--format]' + APP_ARGS 
     1455dump_data.args = '[--format] [--indent]' + APP_ARGS 
    14561456 
    14571457# Utilities for command-line script 
  • django/branches/unicode/django/newforms/extras/widgets.py

    r4265 r5279  
    33""" 
    44 
     5import datetime 
     6 
    57from django.newforms.widgets import Widget, Select 
    68from django.utils.dates import MONTHS 
    7 import datetime 
    89 
    910__all__ = ('SelectDateWidget',) 
  • django/branches/unicode/django/newforms/fields.py

    r5236 r5279  
    33""" 
    44 
    5 from django.utils.translation import ugettext 
    6 from django.utils.encoding import smart_unicode 
    7 from util import ErrorList, ValidationError 
    8 from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple 
    95import datetime 
    106import re 
    117import time 
     8 
     9from django.utils.translation import ugettext 
     10from django.utils.encoding import smart_unicode 
     11 
     12from util import ErrorList, ValidationError 
     13from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple 
    1214 
    1315__all__ = ( 
  • django/branches/unicode/django/newforms/forms.py

    r5241 r5279  
    33""" 
    44 
    5 from django.utils.datastructures import SortedDict, MultiValueDict 
     5import copy 
     6 
     7from django.utils.datastructures import SortedDict 
    68from django.utils.html import escape 
    79from django.utils.encoding import StrAndUnicode, smart_unicode 
     10 
    811from fields import Field 
    9 from widgets import TextInput, Textarea, HiddenInput, MultipleHiddenInput 
     12from widgets import TextInput, Textarea 
    1013from util import flatatt, ErrorDict, ErrorList, ValidationError 
    11 import copy 
    1214 
    1315__all__ = ('BaseForm', 'Form') 
  • django/branches/unicode/django/newforms/models.py

    r5241 r5279  
    66from django.utils.translation import ugettext 
    77from django.utils.encoding import smart_unicode 
     8 
    89from util import ValidationError 
    9 from forms import BaseForm, DeclarativeFieldsMetaclass, SortedDictFromList 
     10from forms import BaseForm, SortedDictFromList 
    1011from fields import Field, ChoiceField 
    1112from widgets import Select, SelectMultiple, MultipleHiddenInput 
    1213 
    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
    1518 
    1619def save_instance(form, instance, fields=None, fail_message='saved', commit=True): 
  • django/branches/unicode/django/newforms/util.py

    r5223 r5279  
    1 from django.conf import settings 
    21from django.utils.html import escape 
    3 from django.utils.functional import Promise, lazy 
    42from django.utils.encoding import smart_unicode 
    53 
  • django/branches/unicode/django/newforms/widgets.py

    r5229 r5279  
    33""" 
    44 
    5 __all__ = ( 
    6     'Widget', 'TextInput', 'PasswordInput', 'HiddenInput', 'MultipleHiddenInput', 
    7     'FileInput', 'Textarea', 'CheckboxInput', 
    8     'Select', 'NullBooleanSelect', 'SelectMultiple', 'RadioSelect', 'CheckboxSelectMultiple', 
    9     'MultiWidget', 'SplitDateTimeWidget', 
    10 
    11  
    12 from util import flatatt 
     5try: 
     6    set # Only available in Python 2.4+ 
     7except NameError: 
     8    from sets import Set as set # Python 2.3 fallback 
     9from itertools import chain 
     10 
    1311from django.utils.datastructures import MultiValueDict 
    1412from django.utils.html import escape 
    1513from django.utils.translation import ugettext 
    1614from django.utils.encoding import StrAndUnicode, smart_unicode 
    17 from itertools import chain 
    18  
    19 try: 
    20     set # Only available in Python 2.4+ 
    21 except NameError: 
    22     from sets import Set as set # Python 2.3 fallback 
     15 
     16from 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
    2325 
    2426class Widget(object): 
  • django/branches/unicode/docs/contributing.txt

    r5185 r5279  
    280280      for details. 
    281281 
    282     * In Django template code, put one (and only one) space between the curly 
    283       brackets and the tag contents. 
    284  
    285       Do this:: 
    286  
    287           {{ foo }} 
    288  
    289       Don't do this:: 
    290  
    291           {{foo}} 
    292  
    293     * In Django views, the first parameter in a view function should be called 
    294       ``request``. 
    295  
    296       Do this:: 
    297  
    298           def my_view(request, foo): 
    299               # ... 
    300  
    301       Don't do this:: 
    302  
    303           def my_view(req, foo): 
    304               # ... 
    305  
    306282    * Please don't put your name in the code you contribute. Our policy is to 
    307283      keep contributors' names in the ``AUTHORS`` file distributed with Django 
     
    309285      change to the ``AUTHORS`` file in your patch if you make more than a 
    310286      single trivial change. 
     287 
     288Template style 
     289-------------- 
     290 
     291    * In Django template code, put one (and only one) space between the curly 
     292      brackets and the tag contents. 
     293 
     294      Do this:: 
     295 
     296          {{ foo }} 
     297 
     298      Don't do this:: 
     299 
     300          {{foo}} 
     301 
     302View style 
     303---------- 
     304 
     305    * In Django views, the first parameter in a view function should be called 
     306      ``request``. 
     307 
     308      Do this:: 
     309 
     310          def my_view(request, foo): 
     311              # ... 
     312 
     313      Don't do this:: 
     314 
     315          def my_view(req, foo): 
     316              # ... 
     317 
     318Model 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          ) 
    311384 
    312385Committing code 
  • django/branches/unicode/docs/db-api.txt

    r5126 r5279  
    144144 
    145145    * 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 
    148148      primary key already exists. 
    149149    * If the record with the given primary key does already exist, Django 
     
    526526    >>> Entry.objects.filter(headline__contains='Lennon').dates('pub_date', 'day') 
    527527    [datetime.datetime(2005, 3, 20)] 
    528      
     528 
    529529``none()`` 
    530530~~~~~~~~~~ 
     
    532532**New in Django development version** 
    533533 
    534 Returns an ``EmptyQuerySet`` -- a ``QuerySet`` that always evaluates to  
     534Returns an ``EmptyQuerySet`` -- a ``QuerySet`` that always evaluates to 
    535535an empty list. This can be used in cases where you know that you should 
    536536return an empty result set and your caller is expecting a ``QuerySet`` 
     
    538538 
    539539Examples:: 
    540      
     540 
    541541    >>> Entry.objects.none() 
    542542    [] 
     
    611611 
    612612The ``depth`` argument is new in the Django development version. 
    613      
     613 
    614614``extra(select=None, where=None, params=None, tables=None)`` 
    615615~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    11371137~~~~~~ 
    11381138 
    1139 Takes either ``True`` or ``False``, which correspond to SQL queries of  
     1139Takes either ``True`` or ``False``, which correspond to SQL queries of 
    11401140``IS NULL`` and ``IS NOT NULL``, respectively. 
    11411141 
     
    11501150.. admonition:: ``__isnull=True`` vs ``__exact=None`` 
    11511151 
    1152     There is an important difference between ``__isnull=True`` and  
     1152    There is an important difference between ``__isnull=True`` and 
    11531153    ``__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 
    11561156    of ``NULL`` without performing a comparison. 
    11571157 
     
    11821182 
    11831183For convenience, Django provides a ``pk`` lookup type, which stands for 
    1184 "primary_key".  
     1184"primary_key". 
    11851185 
    11861186In the example ``Blog`` model, the primary key is the ``id`` field, so these 
     
    11911191    Blog.objects.get(pk=14) # pk implies id__exact 
    11921192 
    1193 The use of ``pk`` isn't limited to ``__exact`` queries -- any query term  
     1193The use of ``pk`` isn't limited to ``__exact`` queries -- any query term 
    11941194can be combined with ``pk`` to perform a query on the primary key of a model:: 
    11951195 
     
    11971197    Blog.objects.filter(pk__in=[1,4,7]) 
    11981198    # Get all blog entries with id > 14 
    1199     Blog.objects.filter(pk__gt=14)  
    1200      
     1199    Blog.objects.filter(pk__gt=14) 
     1200 
    12011201``pk`` lookups also work across joins. For example, these three statements are 
    12021202equivalent:: 
     
    17551755 
    17561756One 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  
     1757object doesn't exist. This idiom is captured by ``get_object_or_404()``. 
     1758This function takes a Django model as its first argument and an 
     1759arbitrary number of keyword arguments, which it passes to the manager's 
    17601760``get()`` function. It raises ``Http404`` if the object doesn't 
    1761 exist. For example::  
    1762      
     1761exist. For example:: 
     1762 
    17631763    # Get the Entry with a primary key of 3 
    17641764    e = get_object_or_404(Entry, pk=3) 
    17651765 
    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.  
     1766When you provide a model to this shortcut function, the default manager 
     1767is used to execute the underlying ``get()`` query. If you don't want to 
     1768use the default manager, or if you want to search a list of related objects, 
     1769you can provide ``get_object_or_404()`` with a manager object instead. 
    17701770For example:: 
    17711771 
     
    17801780----------------- 
    17811781 
    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 
    17841784``Http404`` if the list is empty. 
    17851785 
  • django/branches/unicode/docs/model-api.txt

    r5185 r5279  
    17601760    <a href="{{ object.get_absolute_url }}">{{ object.name }}</a> 
    17611761 
     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 
    17621771The ``permalink`` decorator 
    17631772~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • django/branches/unicode/docs/syndication_feeds.txt

    r5151 r5279  
    147147      passing it a single parameter, ``item``, which is the object itself. 
    148148      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. 
    150153 
    151154    * For the LatestEntries example above, we could have very simple feed templates: 
  • django/branches/unicode/extras/django_bash_completion

    r4677 r5279  
    4343 
    4444    # Standalone options 
    45     opts="--help --settings --pythonpath --version" 
     45    opts="--help --settings --pythonpath --noinput --noreload --format --indent --verbosity --adminmedia --version" 
    4646    # Actions 
    4747    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
    5050             sqlreset sqlsequencereset startapp startproject \ 
    51              syncdb validate" 
     51             syncdb test validate" 
    5252    # Action's options 
    5353    action_shell_opts="--plain" 
     
    8585    else 
    8686        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 
    99100                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                ;; 
    114114 
    115115            createcachetable|dbshell|diffsettings| \