Changeset 4142
- Timestamp:
- 11/29/06 14:16:50 (2 years ago)
- Files:
-
- django/branches/multiple-db-support/AUTHORS (modified) (1 diff)
- django/branches/multiple-db-support/django/conf/global_settings.py (modified) (1 diff)
- django/branches/multiple-db-support/django/conf/locale/de/LC_MESSAGES/django.mo (modified) (previous)
- django/branches/multiple-db-support/django/conf/locale/de/LC_MESSAGES/django.po (modified) (14 diffs)
- django/branches/multiple-db-support/django/conf/locale/zh_CN/LC_MESSAGES/djangojs.mo (modified) (previous)
- django/branches/multiple-db-support/django/conf/locale/zh_CN/LC_MESSAGES/djangojs.po (modified) (4 diffs)
- django/branches/multiple-db-support/django/conf/locale/zh_CN/LC_MESSAGES/django.mo (modified) (previous)
- django/branches/multiple-db-support/django/conf/locale/zh_CN/LC_MESSAGES/django.po (modified) (2 diffs)
- django/branches/multiple-db-support/django/contrib/auth/decorators.py (modified) (1 diff)
- django/branches/multiple-db-support/django/contrib/auth/forms.py (modified) (6 diffs)
- django/branches/multiple-db-support/django/core/management.py (modified) (1 diff)
- django/branches/multiple-db-support/django/core/servers/basehttp.py (modified) (1 diff)
- django/branches/multiple-db-support/django/core/validators.py (modified) (2 diffs)
- django/branches/multiple-db-support/django/db/backends/ansi/sql.py (modified) (1 diff)
- django/branches/multiple-db-support/django/db/models/fields/__init__.py (modified) (1 diff)
- django/branches/multiple-db-support/django/db/models/fields/related.py (modified) (1 diff)
- django/branches/multiple-db-support/django/db/models/manipulators.py (modified) (1 diff)
- django/branches/multiple-db-support/django/db/models/query.py (modified) (2 diffs)
- django/branches/multiple-db-support/django/forms/__init__.py (modified) (2 diffs)
- django/branches/multiple-db-support/django/middleware/common.py (modified) (1 diff)
- django/branches/multiple-db-support/django/views/generic/create_update.py (modified) (3 diffs)
- django/branches/multiple-db-support/docs/apache_auth.txt (modified) (1 diff)
- django/branches/multiple-db-support/docs/authentication.txt (modified) (3 diffs)
- django/branches/multiple-db-support/docs/contributing.txt (modified) (2 diffs)
- django/branches/multiple-db-support/docs/db-api.txt (modified) (2 diffs)
- django/branches/multiple-db-support/docs/django-admin.txt (modified) (1 diff)
- django/branches/multiple-db-support/docs/forms.txt (modified) (5 diffs)
- django/branches/multiple-db-support/docs/model-api.txt (modified) (1 diff)
- django/branches/multiple-db-support/docs/serialization.txt (modified) (8 diffs)
- django/branches/multiple-db-support/docs/settings.txt (modified) (1 diff)
- django/branches/multiple-db-support/tests/modeltests/basic/models.py (modified) (1 diff)
- django/branches/multiple-db-support/tests/modeltests/custom_pk/models.py (modified) (1 diff)
- django/branches/multiple-db-support/tests/modeltests/one_to_one/models.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/multiple-db-support/AUTHORS
r4141 r4142 83 83 Brant Harris 84 84 heckj@mac.com 85 Joel Heenan <joelh-django@planetjoel.com> 85 86 hipertracker@gmail.com 86 87 Ian Holsman <http://feh.holsman.net/> django/branches/multiple-db-support/django/conf/global_settings.py
r4141 r4142 278 278 279 279 # The profanities that will trigger a validation error in the 280 # 'hasNoProfanities' validator. All of these should be in lower -case.281 PROFANITIES_LIST = ['asshat', 'asshead', 'asshole', 'cunt', 'fuck', 'gook', 'nigger', 'shit']280 # 'hasNoProfanities' validator. All of these should be in lowercase. 281 PROFANITIES_LIST = ('asshat', 'asshead', 'asshole', 'cunt', 'fuck', 'gook', 'nigger', 'shit') 282 282 283 283 # The group ID that designates which users are banned. django/branches/multiple-db-support/django/conf/locale/de/LC_MESSAGES/django.po
r4141 r4142 8 8 "Project-Id-Version: Django 1.0\n" 9 9 "Report-Msgid-Bugs-To: \n" 10 "POT-Creation-Date: 2006-09-25 1 5:39+0200\n"10 "POT-Creation-Date: 2006-09-25 16:04+0200\n" 11 11 "PO-Revision-Date: 2005-10-08 00:03+0200\n" 12 12 "Last-Translator: Georg Bauer <gb@bofh.ms>\n" … … 584 584 585 585 #: contrib/admin/views/doc.py:164 586 #, python-format 586 587 msgid "App %r not found" 587 588 msgstr "Anwendung %r nicht gefunden" … … 823 824 824 825 #: contrib/admin/templates/admin/index.html:18 826 #, python-format 825 827 msgid "%(name)s" 826 828 msgstr "%(name)s" … … 868 870 869 871 #: contrib/admin/templates/admin/delete_confirmation.html:14 872 #, python-format 870 873 msgid "" 871 874 "Deleting the %(object_name)s '%(escaped_object)s' would result in deleting " … … 878 881 879 882 #: contrib/admin/templates/admin/delete_confirmation.html:21 883 #, python-format 880 884 msgid "" 881 885 "Are you sure you want to delete the %(object_name)s \"%(escaped_object)s\"? " 882 886 "All of the following related items will be deleted:" 883 887 msgstr "" 884 "Sind Sie sicher, das Sie %(object_name)s \"%(escaped_object)s\" l�en wollen? Es"885 "w erden zus�lich die folgenden abh�igen Daten mit gel�t:"888 "Sind Sie sicher, das Sie %(object_name)s \"%(escaped_object)s\" l�en " 889 "wollen? Es werden zus�lich die folgenden abh�igen Daten mit gel�t:" 886 890 887 891 #: contrib/admin/templates/admin/delete_confirmation.html:26 … … 890 894 891 895 #: contrib/admin/templates/admin/filter.html:2 896 #, python-format 892 897 msgid " By %(filter_title)s " 893 898 msgstr " Nach %(filter_title)s " … … 956 961 "the appropriate user." 957 962 msgstr "" 958 "Irgendetwas ist falsch mit der Datenbankkonfiguration. Bitte sicherstellen, das"959 "d ie richtigen Datenbanktabellen angelegt wurden und bitte sicherstellen, das die"960 " Datenbank vom verwendeten Datenbankbenutzer auch lesbar ist."963 "Irgendetwas ist falsch mit der Datenbankkonfiguration. Bitte sicherstellen, " 964 "das die richtigen Datenbanktabellen angelegt wurden und bitte sicherstellen, " 965 "das die Datenbank vom verwendeten Datenbankbenutzer auch lesbar ist." 961 966 962 967 #: contrib/admin/templates/admin/auth/user/add_form.html:6 … … 1246 1251 "will use 'flatpages/default.html'." 1247 1252 msgstr "" 1248 "Beispiel: 'flatpages/contact_page.html'. Wenn dieses Feld nicht gef�st, wird"1249 " 'flatpages/default.html' als Standard gew�t."1253 "Beispiel: 'flatpages/contact_page.html'. Wenn dieses Feld nicht gef�st, " 1254 "wird 'flatpages/default.html' als Standard gew�t." 1250 1255 1251 1256 #: contrib/flatpages/models.py:14 … … 1344 1349 "instead of deleting accounts." 1345 1350 msgstr "" 1346 "Gibt an, ob der Benutzer sich an der Administrationsseite anmelden kann. Anstelle"1347 " Benutzer zu l�en, kann das hier auch einfach abgeschaltet werden."1351 "Gibt an, ob der Benutzer sich an der Administrationsseite anmelden kann. " 1352 "Anstelle Benutzer zu l�en, kann das hier auch einfach abgeschaltet werden." 1348 1353 1349 1354 #: contrib/auth/models.py:97 … … 1417 1422 msgid "This account is inactive." 1418 1423 msgstr "Dieser Benutzer ist inaktiv." 1424 1425 #: contrib/auth/forms.py:84 1426 msgid "" 1427 "That e-mail address doesn't have an associated user acount. Are you sure " 1428 "you've registered?" 1429 msgstr "" 1430 "Die Email-Adresse hat keinen Benutzer zugeordnet. Sicher, das die Adresse " 1431 "hier angemeldet ist?" 1432 1433 #: contrib/auth/forms.py:116 1434 msgid "The two 'new password' fields didn't match." 1435 msgstr "Die zwei Passw�r sind nicht gleich." 1436 1437 #: contrib/auth/forms.py:123 1438 msgid "Your old password was entered incorrectly. Please enter it again." 1439 msgstr "Das alte Passwort war falsch. Bitte neu eingeben." 1419 1440 1420 1441 #: contrib/contenttypes/models.py:20 … … 1865 1886 1866 1887 #: core/validators.py:142 1888 #, python-format 1867 1889 msgid "Invalid date: %s." 1868 1890 msgstr "Ung�s Datum: %s" … … 1888 1910 #: core/validators.py:172 core/validators.py:401 forms/__init__.py:661 1889 1911 msgid "No file was submitted. Check the encoding type on the form." 1890 msgstr "Es wurde keine Datei geschickt. Eventuell ist das Formular-Encoding falsch." 1912 msgstr "" 1913 "Es wurde keine Datei geschickt. Eventuell ist das Formular-Encoding falsch." 1891 1914 1892 1915 #: core/validators.py:176 … … 2000 2023 2001 2024 #: core/validators.py:381 2025 #, python-format 2002 2026 msgid "" 2003 2027 "Please enter a valid decimal number with a whole part of at most %s digit." … … 2104 2128 2105 2129 #: views/generic/create_update.py:43 2130 #, python-format 2106 2131 msgid "The %(verbose_name)s was created successfully." 2107 2132 msgstr "%(verbose_name)s wurde erfolgreich angelegt." 2108 2133 2109 2134 #: views/generic/create_update.py:117 2135 #, python-format 2110 2136 msgid "The %(verbose_name)s was updated successfully." 2111 2137 msgstr "%(verbose_name)s wurde erfolgreich aktualisiert." 2112 2138 2113 2139 #: views/generic/create_update.py:184 2140 #, python-format 2114 2141 msgid "The %(verbose_name)s was deleted." 2115 2142 msgstr "%(verbose_name)s wurde gel�t" django/branches/multiple-db-support/django/conf/locale/zh_CN/LC_MESSAGES/djangojs.po
r3227 r4142 4 4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. 5 5 # 6 #, fuzzy7 6 msgid "" 8 7 msgstr "" 9 "Project-Id-Version: PACKAGE VERSION\n"8 "Project-Id-Version: Django 0.95\n" 10 9 "Report-Msgid-Bugs-To: \n" 11 10 "POT-Creation-Date: 2006-03-21 18:43+0800\n" 12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"13 "Last-Translator: FULL NAME <max@exoweb.net>\n"14 "Language-Team: LANGUAGE <LL@li.org>\n"11 "PO-Revision-Date: 2006-09-25 08:35+0800\n" 12 "Last-Translator: limodou <limodou@gmail.com>\n" 13 "Language-Team: limodou <limodou@gmail.com>\n" 15 14 "MIME-Version: 1.0\n" 16 15 "Content-Type: text/plain; charset=utf-8\n" … … 19 18 #: contrib/admin/media/js/SelectFilter2.js:33 20 19 msgid "Available %s" 21 msgstr "可 行%s"20 msgstr "可用 %s" 22 21 23 22 #: contrib/admin/media/js/SelectFilter2.js:41 … … 31 30 #: contrib/admin/media/js/SelectFilter2.js:48 32 31 msgid "Remove" 33 msgstr " 移出"32 msgstr "删除" 34 33 35 34 #: contrib/admin/media/js/SelectFilter2.js:53 36 35 msgid "Chosen %s" 37 msgstr "选 择%s"36 msgstr "选中的 %s" 38 37 39 38 #: contrib/admin/media/js/SelectFilter2.js:54 40 39 msgid "Select your choice(s) and click " 41 msgstr " 挑选你的选择并且点击 "40 msgstr "选择并点击 " 42 41 43 42 #: contrib/admin/media/js/SelectFilter2.js:59 44 43 msgid "Clear all" 45 msgstr "清除 所有"44 msgstr "清除全部" 46 45 47 46 #: contrib/admin/media/js/dateparse.js:32 48 47 #: contrib/admin/media/js/calendar.js:24 49 msgid "" 50 "January February March April May June July August September October November " 51 "December" 48 msgid "January February March April May June July August September October November December" 52 49 msgstr "一月 二月 三月 四月 五月 六月 六月 七月 八月 九月 十月 十一月 十二月" 53 50 54 51 #: contrib/admin/media/js/dateparse.js:33 55 52 msgid "Sunday Monday Tuesday Wednesday Thursday Friday Saturday" 56 msgstr "星期 天星期一 星期二 星期三 星期四 星期五 星期六"53 msgstr "星期日 星期一 星期二 星期三 星期四 星期五 星期六" 57 54 58 55 #: contrib/admin/media/js/calendar.js:25 59 56 msgid "S M T W T F S" 60 msgstr "日 月 火 水 木 金 土"57 msgstr "日 一 二 三 四 五 六" 61 58 62 59 #: contrib/admin/media/js/admin/DateTimeShortcuts.js:45 … … 106 103 msgid "Tomorrow" 107 104 msgstr "明天" 105 django/branches/multiple-db-support/django/conf/locale/zh_CN/LC_MESSAGES/django.po
r2933 r4142 9 9 "Report-Msgid-Bugs-To: \n" 10 10 "POT-Creation-Date: 2006-05-16 10:10+0200\n" 11 "PO-Revision-Date: 2006-0 5-17 13:47+0800\n"11 "PO-Revision-Date: 2006-09-01 22:05+0800\n" 12 12 "Last-Translator: limodou <limodou@gmail.com>\n" 13 13 "Language-Team: Simplified Chinese <limodou@gmail.com>\n" … … 1168 1168 #: contrib/auth/models.py:77 1169 1169 msgid "Permissions" 1170 msgstr " 许可"1170 msgstr "权限" 1171 1171 1172 1172 #: contrib/auth/models.py:78 django/branches/multiple-db-support/django/contrib/auth/decorators.py
r4139 r4142 30 30 def permission_required(perm, login_url=LOGIN_URL): 31 31 """ 32 Decorator for views that checks ifa user has a particular permission33 enabled, redirecti ing to the log-in page if necessary.32 Decorator for views that checks whether a user has a particular permission 33 enabled, redirecting to the log-in page if necessary. 34 34 """ 35 35 return user_passes_test(lambda u: u.has_perm(perm), login_url=login_url) django/branches/multiple-db-support/django/contrib/auth/forms.py
r3523 r4142 5 5 from django.core import validators 6 6 from django import forms 7 from django.utils.translation import gettext_lazy as _ 7 8 8 9 class UserCreationForm(forms.Manipulator): … … 14 15 forms.PasswordField(field_name='password1', length=30, maxlength=60, is_required=True), 15 16 forms.PasswordField(field_name='password2', length=30, maxlength=60, is_required=True, 16 validator_list=[validators.AlwaysMatchesOtherField('password1', "The two password fields didn't match.")]),17 validator_list=[validators.AlwaysMatchesOtherField('password1', _("The two password fields didn't match."))]), 17 18 ) 18 19 … … 22 23 except User.DoesNotExist: 23 24 return 24 raise validators.ValidationError, 'A user with that username already exists.'25 raise validators.ValidationError, _('A user with that username already exists.') 25 26 26 27 def save(self, new_data): … … 82 83 self.user_cache = User.objects.get(email__iexact=new_data) 83 84 except User.DoesNotExist: 84 raise validators.ValidationError, "That e-mail address doesn't have an associated user acount. Are you sure you've registered?"85 raise validators.ValidationError, _("That e-mail address doesn't have an associated user acount. Are you sure you've registered?") 85 86 86 87 def save(self, domain_override=None, email_template_name='registration/password_reset_email.html'): … … 114 115 validator_list=[self.isValidOldPassword]), 115 116 forms.PasswordField(field_name="new_password1", length=30, maxlength=30, is_required=True, 116 validator_list=[validators.AlwaysMatchesOtherField('new_password2', "The two 'new password' fields didn't match.")]),117 validator_list=[validators.AlwaysMatchesOtherField('new_password2', _("The two 'new password' fields didn't match."))]), 117 118 forms.PasswordField(field_name="new_password2", length=30, maxlength=30, is_required=True), 118 119 ) … … 121 122 "Validates that the old_password field is correct." 122 123 if not self.user.check_password(new_data): 123 raise validators.ValidationError, "Your old password was entered incorrectly. Please enter it again."124 raise validators.ValidationError, _("Your old password was entered incorrectly. Please enter it again.") 124 125 125 126 def save(self, new_data): django/branches/multiple-db-support/django/core/management.py
r4139 r4142 1129 1129 type='choice', choices=['0', '1', '2'], 1130 1130 help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'), 1131 parser.add_option('--adminmedia', dest='admin_media_path', default='', help=' Lets you manually specify the directory to serve admin media from when running the developmentserver.'),1131 parser.add_option('--adminmedia', dest='admin_media_path', default='', help='Specifies the directory from which to serve admin media for runserver.'), 1132 1132 1133 1133 options, args = parser.parse_args(argv[1:]) django/branches/multiple-db-support/django/core/servers/basehttp.py
r4139 r4142 595 595 security and is not super efficient. 596 596 """ 597 def __init__(self, application, media_dir =None):597 def __init__(self, application, media_dir=None): 598 598 from django.conf import settings 599 599 self.application = application django/branches/multiple-db-support/django/core/validators.py
r4141 r4142 250 250 """ 251 251 field_data = field_data.lower() # normalize 252 words_seen = [w for w in settings.PROFANITIES_LIST if field_data.find(w) > -1]252 words_seen = [w for w in settings.PROFANITIES_LIST if w in field_data] 253 253 if words_seen: 254 254 from django.utils.text import get_text_list … … 378 378 raise ValidationError, ngettext("Please enter a valid decimal number with at most %s total digit.", 379 379 "Please enter a valid decimal number with at most %s total digits.", self.max_digits) % self.max_digits 380 if (not '.' in data and len(data) > (max_allowed_length - self.decimal_places )) or ('.' in data and len(data) > (self.max_digits - (self.decimal_places - len(data.split('.')[1])) + 1)):380 if (not '.' in data and len(data) > (max_allowed_length - self.decimal_places - 1)) or ('.' in data and len(data) > (max_allowed_length - (self.decimal_places - len(data.split('.')[1])))): 381 381 raise ValidationError, ngettext( "Please enter a valid decimal number with a whole part of at most %s digit.", 382 382 "Please enter a valid decimal number with a whole part of at most %s digits.", str(self.max_digits-self.decimal_places)) % str(self.max_digits-self.decimal_places) django/branches/multiple-db-support/django/db/backends/ansi/sql.py
r4141 r4142 74 74 75 75 for f in opts.fields: 76 if isinstance(f, models.ForeignKey):76 if isinstance(f, (models.ForeignKey, models.OneToOneField)): 77 77 rel_field = f.rel.get_related_field() 78 78 data_type = self.get_rel_data_type(rel_field) django/branches/multiple-db-support/django/db/models/fields/__init__.py
r3581 r4142 368 368 def to_python(self, value): 369 369 if value in (True, False): return value 370 if value in ('t', 'True' ): return True371 if value in ('f', 'False' ): return False370 if value in ('t', 'True', '1'): return True 371 if value in ('f', 'False', '0'): return False 372 372 raise validators.ValidationError, gettext("This value must be either True or False.") 373 373 django/branches/multiple-db-support/django/db/models/fields/related.py
r3523 r4142 619 619 else: 620 620 msg = gettext_lazy('Hold down "Control", or "Command" on a Mac, to select more than one.') 621 self.help_text = string_concat(self.help_text, msg)621 self.help_text = string_concat(self.help_text, ' ', msg) 622 622 623 623 def get_manipulator_field_objs(self): django/branches/multiple-db-support/django/db/models/manipulators.py
r3581 r4142 216 216 for f in related.opts.many_to_many: 217 217 if child_follow.get(f.name, None) and not f.rel.edit_inline: 218 was_changed = getattr(new_rel_obj, 'set_%s' % f.name)(rel_new_data[f.attname])219 if self.change and was_changed:218 setattr(new_rel_obj, f.name, f.rel.to.objects.filter(pk__in=rel_new_data[f.attname])) 219 if self.change: 220 220 self.fields_changed.append('%s for %s "%s"' % (f.verbose_name, related.opts.verbose_name, new_rel_obj)) 221 221 django/branches/multiple-db-support/django/db/models/query.py
r3427 r4142 733 733 # The very-last is the lookup_type (equals, like, etc). 734 734 # The second-last is the table column on which the lookup_type is 735 # to be performed. 736 # The exceptions to this are: 737 # 1) "pk", which is an implicit id__exact; 738 # if we find "pk", make the lookup_type "exact', and insert 739 # a dummy name of None, which we will replace when 740 # we know which table column to grab as the primary key. 741 # 2) If there is only one part, or the last part is not a query 742 # term, assume that the query is an __exact 735 # to be performed. If this name is 'pk', it will be substituted with 736 # the name of the primary key. 737 # If there is only one part, or the last part is not a query 738 # term, assume that the query is an __exact 743 739 lookup_type = path.pop() 744 740 if lookup_type == 'pk': … … 790 786 # Has the primary key been requested? If so, expand it out 791 787 # to be the name of the current class' primary key 792 if name is None :788 if name is None or name == 'pk': 793 789 name = current_opts.pk.name 794 790 django/branches/multiple-db-support/django/forms/__init__.py
r4141 r4142 55 55 "Returns dictionary mapping field_names to error-message lists" 56 56 errors = {} 57 self.prepare(new_data) 57 58 for field in self.fields: 58 59 errors.update(field.get_validation_errors(new_data)) … … 639 640 checked_html = ' checked="checked"' 640 641 field_name = '%s%s' % (self.field_name, value) 641 output.append('<li><input type="checkbox" id="%s" class="v%s" name="%s"%s /> <label for="%s">%s</label></li>' % \642 output.append('<li><input type="checkbox" id="%s" class="v%s" name="%s"%s value="on" /> <label for="%s">%s</label></li>' % \ 642 643 (self.get_id() + escape(value), self.__class__.__name__, field_name, checked_html, 643 644 self.get_id() + escape(value), choice)) django/branches/multiple-db-support/django/middleware/common.py
r4139 r4142 65 65 path = request.get_full_path() 66 66 if referer and not _is_ignorable_404(path) and (is_internal or '?' not in referer): 67 ua = request.META.get('HTTP_USER_AGENT', '<none>')67 ua = request.META.get('HTTP_USER_AGENT', '<none>') 68 68 mail_managers("Broken %slink on %s" % ((is_internal and 'INTERNAL ' or ''), domain), 69 "Referrer: %s\nRequested URL: %s\nUser Agent: %s\n" % (referer, request.get_full_path(), ua))69 "Referrer: %s\nRequested URL: %s\nUser agent: %s\n" % (referer, request.get_full_path(), ua)) 70 70 return response 71 71 django/branches/multiple-db-support/django/views/generic/create_update.py
r3581 r4142 103 103 raise Http404, "No %s found for %s" % (model._meta.verbose_name, lookup_kwargs) 104 104 105 manipulator = model.ChangeManipulator(getattr(object, object._meta.pk. name), follow=follow)105 manipulator = model.ChangeManipulator(getattr(object, object._meta.pk.attname), follow=follow) 106 106 107 107 if request.POST: … … 143 143 c[key] = value 144 144 response = HttpResponse(t.render(c)) 145 populate_xheaders(request, response, model, getattr(object, object._meta.pk. name))145 populate_xheaders(request, response, model, getattr(object, object._meta.pk.attname)) 146 146 return response 147 147 … … 197 197 c[key] = value 198 198 response = HttpResponse(t.render(c)) 199 populate_xheaders(request, response, model, getattr(object, object._meta.pk. name))199 populate_xheaders(request, response, model, getattr(object, object._meta.pk.attname)) 200 200 return response django/branches/multiple-db-support/docs/apache_auth.txt
r3012 r4142 7 7 `authentication system`_ directly. For example, you could: 8 8 9 * Serve media files directly from Apache only to authenticated users.9 * Serve static/media files directly from Apache only to authenticated users. 10 10 11 11 * Authenticate access to a Subversion_ repository against Django users with django/branches/multiple-db-support/docs/authentication.txt
r4139 r4142 457 457 my_view = user_passes_test(lambda u: u.has_perm('polls.can_vote'))(my_view) 458 458 459 We are using this particular test as a relatively simple example, however be460 aware that if you just want to test if a permission is available to a user, 461 you can use the ``permission_required()`` decorator described below.459 We're using this particular test as a relatively simple example. However, if 460 you just want to test whether a permission is available to a user, you can use 461 the ``permission_required()`` decorator, described later in this document. 462 462 463 463 Here's the same thing, using Python 2.4's decorator syntax:: … … 496 496 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 497 497 498 Since checking whether a user has a particular permission available to them is a 499 relatively common operation, Django provides a shortcut for that particular 500 case: the ``permission_required()`` decorator. Using this decorator, the 501 earlier example can be written as:: 498 **New in Django development version** 499 500 It's a relatively common task to check whether a user has a particular 501 permission. For that reason, Django provides a shortcut for that case: the 502 ``permission_required()`` decorator. Using this decorator, the earlier example 503 can be written as:: 502 504 503 505 from django.contrib.auth.decorators import permission_required 504 505 def my_view(request): 506 # ... 507 506 507 def my_view(request): 508 # ... 508 509 my_view = permission_required('polls.can_vote')(my_view) 509 510 510 511 Note that ``permission_required()`` also takes an optional ``login_url`` 511 parameter. 512 parameter. Example:: 513 514 from django.contrib.auth.decorators import permission_required 515 516 def my_view(request): 517 # ... 518 my_view = permission_required('polls.can_vote', login_url='/loginpage/')(my_view) 519 520 As in the ``login_required`` decorator, ``login_url`` defaults to 521 ``'/accounts/login/'``. 512 522 513 523 Limiting access to generic views … … 634 644 635 645 {% if user.is_authenticated %} 636 <p>Welcome, {{ user.username }}. Thanks for logging in.</p> 646 <p>Welcome, {{ user.username }}. Thanks for logging in.</p> 637 647 {% else %} 638 648 <p>Welcome, new user. Please log in.</p> django/branches/multiple-db-support/docs/contributing.txt
r4139 r4142 260 260 261 261 The Django tests all use the testing infrastructure that ships with Django for 262 testing applications. See `Testing Django Applications`_ for an explanation of262 testing applications. See `Testing Django applications`_ for an explanation of 263 263 how to write new tests. 264 264 265 .. _Testing Django Applications: http://www.djangoproject.com/documentation/testing/265 .. _Testing Django applications: http://www.djangoproject.com/documentation/testing/ 266 266 267 267 Running the unit tests … … 274 274 Yes, the unit tests need a settings module, but only for database connection 275 275 info -- the ``DATABASE_ENGINE``, ``DATABASE_USER`` and ``DATABASE_PASSWORD``. 276 You will also need a ``ROOT_URLCONF`` setting (it 's value is ignored; it just276 You will also need a ``ROOT_URLCONF`` setting (its value is ignored; it just 277 277 needs to be present) and a ``SITE_ID`` setting (any integer value will do) in 278 278 order for all the tests to pass. django/branches/multiple-db-support/docs/db-api.txt
r4139 r4142 1141 1141 1142 1142 For convenience, Django provides a ``pk`` lookup type, which stands for 1143 "primary_key". This is shorthand for "an exact lookup on the primary-key."1143 "primary_key". 1144 1144 1145 1145 In the example ``Blog`` model, the primary key is the ``id`` field, so these … … 1150 1150 Blog.objects.get(pk=14) # pk implies id__exact 1151 1151 1152 The use of ``pk`` isn't limited to ``__exact`` queries -- any query term 1153 can be combined with ``pk`` to perform a query on the primary key of a model:: 1154 1155 # Get blogs entries with id 1, 4 and 7 1156 Blog.objects.filter(pk__in=[1,4,7]) 1157 # Get all blog entries with id > 14 1158 Blog.objects.filter(pk__gt=14) 1159 1152 1160 ``pk`` lookups also work across joins. For example, these three statements are 1153 1161 equivalent:: django/branches/multiple-db-support/docs/django-admin.txt
r4139 r4142 393 393 django-admin.py manage.py --adminmedia=/tmp/new-admin-style/ 394 394 395 Tell Django where to find the various stylesheets and Javascript files for the396 admin interface when running the development server. Normally these files are 397 served out of the Django source tree, but since some designers change these 398 f iles for their site, this option allows you to test against custom versions.395 Tells Django where to find the various CSS and JavaScript files for the admin 396 interface when running the development server. Normally these files are served 397 out of the Django source tree, but because some designers customize these files 398 for their site, this option allows you to test against custom versions. 399 399 400 400 Extra niceties django/branches/multiple-db-support/docs/forms.txt
r4139 r4142 338 338 339 339 * We set ``new_data`` based upon ``flatten_data()`` from the manipulator. 340 ``flatten_data()`` takes the data from the original object under 341 manipulation, and converts it into a data dictionary that can be used 340 ``flatten_data()`` takes the data from the original object under 341 manipulation, and converts it into a data dictionary that can be used 342 342 to populate form elements with the existing values for the object. 343 343 … … 405 405 form = forms.FormWrapper(manipulator, new_data, errors) 406 406 return render_to_response('contact_form.html', {'form': form}) 407 407 408 408 ``FileField`` and ``ImageField`` special cases 409 409 ============================================== … … 482 482 to put punctuation at the end of your validation messages. 483 483 484 When Are Validators Called?484 When are validators called? 485 485 --------------------------- 486 486 … … 488 488 required fields are present and non-empty. For each field that passes that 489 489 test *and if the form submission contained data* for that field, all the 490 validators for that field are called in turn. The emphasi sed portion in the490 validators for that field are called in turn. The emphasized portion in the 491 491 last sentence is important: if a form field is not submitted (because it 492 492 contains no data -- which is normal HTML behaviour), the validators are not … … 498 498 contribute to the form submission. 499 499 500 If you would like your validator to *always* run, regardless of whether the501 field it is attached to contains any data, set the ``always_test`` attribute502 on thevalidator function. For example::500 If you would like your validator to run *always*, regardless of whether its 501 attached field contains any data, set the ``always_test`` attribute on the 502 validator function. For example:: 503 503 504 504 def my_custom_validator(field_data, all_data): 505 505 # ... 506 507 506 my_custom_validator.always_test = True 508 507 509 508 This validator will always be executed for any field it is attached to. 510 509 511 Ready-made Validators510 Ready-made validators 512 511 --------------------- 513 512 django/branches/multiple-db-support/docs/model-api.txt
r4139 r4142 546 546 If ``False``, the field will not be editable in the admin or via form 547 547 processing using the object's ``AddManipulator`` or ``ChangeManipulator`` 548 classes. Default is ``True``.548 classes. Default is ``True``. 549 549 550 550 ``help_text`` django/branches/multiple-db-support/docs/serialization.txt
r4139 r4142 4 4 5 5 .. note:: 6 6 7 7 This API is currently under heavy development and may change -- 8 8 perhaps drastically -- in the future. 9 9 10 10 You have been warned. 11 11 12 12 Django's serialization framework provides a mechanism for "translating" Django 13 13 objects into other formats. Usually these other formats will be text-based and … … 22 22 from django.core import serializers 23 23 data = serializers.serialize("xml", SomeModel.objects.all()) 24 24 25 25 The arguments to the ``serialize`` function are the format to serialize the 26 26 data to (see `Serialization formats`_) and a QuerySet_ to serialize. … … 35 35 xml_serializer.serialize(queryset) 36 36 data = xml_serializer.getvalue() 37 37 38 38 This is useful if you want to serialize data directly to a file-like object 39 39 (which includes a HTTPResponse_):: … … 51 51 for obj in serializers.deserialize("xml", data): 52 52 do_something_with(obj) 53 53 54 54 As you can see, the ``deserialize`` function takes the same format argument as 55 55 ``serialize``, a string or stream of data, and returns an iterator. … … 70 70 if object_should_be_saved(deserialized_object): 71 71 obj.save() 72 72 73 73 In other words, the usual use is to examine the deserialized objects to make 74 74 sure that they are "appropriate" for saving before doing so. Of course, if you trust your data source you could just save the object and move on. … … 90 90 91 91 ``python`` Translates to and from "simple" Python objects (lists, dicts, 92 strings, etc.). Not really all that useful on its own, but 92 strings, etc.). Not really all that useful on its own, but 93 93 used as a base for other serializers. 94 94 ========== ============================================================== … … 97 97 .. _simplejson: http://undefined.org/python/#simplejson 98 98 99 Notes For Specific Serialization Formats99 Notes for specific serialization formats 100 100 ---------------------------------------- 101 101 … … 103 103 ~~~~ 104 104 105 If you are using UTF-8 (or any other non-ASCII encoding) data with the JSON105 If you're using UTF-8 (or any other non-ASCII encoding) data with the JSON 106 106 serializer, you must pass ``ensure_ascii=False`` as a parameter to the 107 ``serialize()`` call. Otherwise the output will not be encoded correctly.107 ``serialize()`` call. Otherwise, the output won't be encoded correctly. 108 108 109 109 For example:: django/branches/multiple-db-support/docs/settings.txt
r4139 r4142 607 607 ---------------- 608 608 609 A list of profanities that will trigger a validation error when the 610 ``hasNoProfanities`` validator is called. 609 A tuple of profanities, as strings, that will trigger a validation error when 610 the ``hasNoProfanities`` validator is called. 611 612 We don't list the default values here, because that would be profane. To see &nb
