Changeset 3523
- Timestamp:
- 08/04/06 18:27:18 (2 years ago)
- Files:
-
- django/branches/multiple-db-support/AUTHORS (modified) (1 diff)
- django/branches/multiple-db-support/django/conf/locale/ru/LC_MESSAGES/django.mo (modified) (previous)
- django/branches/multiple-db-support/django/conf/locale/ru/LC_MESSAGES/django.po (modified) (2 diffs)
- django/branches/multiple-db-support/django/conf/urls/defaults.py (modified) (1 diff)
- django/branches/multiple-db-support/django/contrib/admin/media/js/admin/DateTimeShortcuts.js (modified) (7 diffs)
- django/branches/multiple-db-support/django/contrib/admin/media/js/admin/RelatedObjectLookups.js (modified) (1 diff)
- django/branches/multiple-db-support/django/contrib/admin/templates/admin/auth (copied) (copied from django/trunk/django/contrib/admin/templates/admin/auth)
- django/branches/multiple-db-support/django/contrib/admin/templates/admin/auth/user (copied) (copied from django/trunk/django/contrib/admin/templates/admin/auth/user)
- django/branches/multiple-db-support/django/contrib/admin/templates/admin/auth/user/add_form.html (copied) (copied from django/trunk/django/contrib/admin/templates/admin/auth/user/add_form.html)
- django/branches/multiple-db-support/django/contrib/admin/urls.py (modified) (1 diff)
- django/branches/multiple-db-support/django/contrib/admin/views/auth.py (copied) (copied from django/trunk/django/contrib/admin/views/auth.py)
- django/branches/multiple-db-support/django/contrib/auth/forms.py (modified) (1 diff)
- django/branches/multiple-db-support/django/core/management.py (modified) (1 diff)
- django/branches/multiple-db-support/django/core/urlresolvers.py (modified) (3 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/middleware/gzip.py (modified) (1 diff)
- django/branches/multiple-db-support/docs/add_ons.txt (modified) (1 diff)
- django/branches/multiple-db-support/docs/db-api.txt (modified) (1 diff)
- django/branches/multiple-db-support/docs/faq.txt (modified) (1 diff)
- django/branches/multiple-db-support/docs/url_dispatch.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/multiple-db-support/AUTHORS
r3502 r3523 71 71 gandalf@owca.info 72 72 Baishampayan Ghose 73 martin.glueck@gmail.com 74 Simon Greenhill <dev@simon.net.nz> 73 75 Espen Grindhaug <http://grindhaug.org/> 74 76 Brant Harris django/branches/multiple-db-support/django/conf/locale/ru/LC_MESSAGES/django.po
r3151 r3523 142 142 143 143 #: contrib/comments/models.py:237 144 #, fuzzy 144 145 msgid "karma score" 145 146 msgstr "Карма счёт" … … 736 737 #, python-format 737 738 msgid "Models available in the %(name)s application." 738 msgstr "Модели доступны в %(name) sприложении."739 msgstr "Модели доступны в %(name) приложении." 739 740 740 741 #: contrib/admin/templates/admin/index.html:28 django/branches/multiple-db-support/django/conf/urls/defaults.py
r411 r3523 11 11 pattern_list = [] 12 12 for t in tuples: 13 if type(t[1]) == list: 14 pattern_list.append(RegexURLResolver(t[0], t[1][0])) 13 regex, view_or_include = t[:2] 14 default_kwargs = t[2:] 15 if type(view_or_include) == list: 16 pattern_list.append(RegexURLResolver(regex, view_or_include[0], *default_kwargs)) 15 17 else: 16 pattern_list.append(RegexURLPattern( t[0], prefix and (prefix + '.' + t[1]) or t[1], *t[2:]))18 pattern_list.append(RegexURLPattern(regex, prefix and (prefix + '.' + view_or_include) or view_or_include, *default_kwargs)) 17 19 return pattern_list django/branches/multiple-db-support/django/contrib/admin/media/js/admin/DateTimeShortcuts.js
r3303 r3523 9 9 calendarDivName1: 'calendarbox', // name of calendar <div> that gets toggled 10 10 calendarDivName2: 'calendarin', // name of <div> that contains calendar 11 calendarLinkName: 'calendarlink',// name of the link that is used to toggle 11 12 clockDivName: 'clockbox', // name of clock <div> that gets toggled 13 clockLinkName: 'clocklink', // name of the link that is used to toggle 12 14 admin_media_prefix: '', 13 15 init: function() { … … 47 49 var clock_link = document.createElement('a'); 48 50 clock_link.setAttribute('href', 'javascript:DateTimeShortcuts.openClock(' + num + ');'); 51 clock_link.id = DateTimeShortcuts.clockLinkName + num; 49 52 quickElement('img', clock_link, '', 'src', DateTimeShortcuts.admin_media_prefix + 'img/admin/icon_clock.gif', 'alt', gettext('Clock')); 50 53 shortcuts_span.appendChild(document.createTextNode('\240')); … … 70 73 clock_box.style.display = 'none'; 71 74 clock_box.style.position = 'absolute'; 72 if (getStyle(document.body,'direction')!='rtl') {73 clock_box.style.left = findPosX(clock_link) + 17 + 'px';74 }75 else {76 // since style's width is in em, it'd be tough to calculate77 // px value of it. let's use an estimated px for now78 // TODO: IE returns wrong value for findPosX when in rtl mode79 // (it returns as it was left aligned), needs to be fixed.80 clock_box.style.left = findPosX(clock_link) - 110 + 'px';81 }82 clock_box.style.top = findPosY(clock_link) - 30 + 'px';83 75 clock_box.className = 'clockbox module'; 84 76 clock_box.setAttribute('id', DateTimeShortcuts.clockDivName + num); … … 99 91 }, 100 92 openClock: function(num) { 101 document.getElementById(DateTimeShortcuts.clockDivName + num).style.display = 'block'; 93 var clock_box = document.getElementById(DateTimeShortcuts.clockDivName+num) 94 var clock_link = document.getElementById(DateTimeShortcuts.clockLinkName+num) 95 96 // Recalculate the clockbox position 97 // is it left-to-right or right-to-left layout ? 98 if (getStyle(document.body,'direction')!='rtl') { 99 clock_box.style.left = findPosX(clock_link) + 17 + 'px'; 100 } 101 else { 102 // since style's width is in em, it'd be tough to calculate 103 // px value of it. let's use an estimated px for now 104 // TODO: IE returns wrong value for findPosX when in rtl mode 105 // (it returns as it was left aligned), needs to be fixed. 106 clock_box.style.left = findPosX(clock_link) - 110 + 'px'; 107 } 108 clock_box.style.top = findPosY(clock_link) - 30 + 'px'; 109 110 // Show the clock box 111 clock_box.style.display = 'block'; 102 112 addEvent(window, 'click', function() { DateTimeShortcuts.dismissClock(num); return true; }); 103 113 }, … … 124 134 var cal_link = document.createElement('a'); 125 135 cal_link.setAttribute('href', 'javascript:DateTimeShortcuts.openCalendar(' + num + ');'); 136 cal_link.id = DateTimeShortcuts.calendarLinkName + num; 126 137 quickElement('img', cal_link, '', 'src', DateTimeShortcuts.admin_media_prefix + 'img/admin/icon_calendar.gif', 'alt', gettext('Calendar')); 127 138 shortcuts_span.appendChild(document.createTextNode('\240')); … … 150 161 cal_box.style.display = 'none'; 151 162 cal_box.style.position = 'absolute'; 152 // is it left-to-right or right-to-left layout ?153 if (getStyle(document.body,'direction')!='rtl') {154 cal_box.style.left = findPosX(cal_link) + 17 + 'px';155 }156 else {157 // since style's width is in em, it'd be tough to calculate158 // px value of it. let's use an estimated px for now159 // TODO: IE returns wrong value for findPosX when in rtl mode160 // (it returns as it was left aligned), needs to be fixed.161 cal_box.style.left = findPosX(cal_link) - 180 + 'px';162 }163 cal_box.style.top = findPosY(cal_link) - 75 + 'px';164 163 cal_box.className = 'calendarbox module'; 165 164 cal_box.setAttribute('id', DateTimeShortcuts.calendarDivName1 + num); … … 196 195 }, 197 196 openCalendar: function(num) { 198 document.getElementById(DateTimeShortcuts.calendarDivName1+num).style.display = 'block'; 197 var cal_box = document.getElementById(DateTimeShortcuts.calendarDivName1+num) 198 var cal_link = document.getElementById(DateTimeShortcuts.calendarLinkName+num) 199 200 // Recalculate the clockbox position 201 // is it left-to-right or right-to-left layout ? 202 if (getStyle(document.body,'direction')!='rtl') { 203 cal_box.style.left = findPosX(cal_link) + 17 + 'px'; 204 } 205 else { 206 // since style's width is in em, it'd be tough to calculate 207 // px value of it. let's use an estimated px for now 208 // TODO: IE returns wrong value for findPosX when in rtl mode 209 // (it returns as it was left aligned), needs to be fixed. 210 cal_box.style.left = findPosX(cal_link) - 180 + 'px'; 211 } 212 cal_box.style.top = findPosY(cal_link) - 75 + 'px'; 213 214 cal_box.style.display = 'block'; 199 215 addEvent(window, 'click', function() { DateTimeShortcuts.dismissCalendar(num); return true; }); 200 216 }, django/branches/multiple-db-support/django/contrib/admin/media/js/admin/RelatedObjectLookups.js
r3066 r3523 12 12 href = triggeringLink.href + '?pop=1'; 13 13 } 14 var win = window.open(href, name, 'height=500,width= 740,resizable=yes,scrollbars=yes');14 var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes'); 15 15 win.focus(); 16 16 return false; django/branches/multiple-db-support/django/contrib/admin/urls.py
r3258 r3523 29 29 ('^doc/templates/(?P<template>.*)/$', 'django.contrib.admin.views.doc.template_detail'), 30 30 31 # "Add user" -- a special-case view 32 ('^auth/user/add/$', 'django.contrib.admin.views.auth.user_add_stage'), 33 31 34 # Add/change/delete/history 32 35 ('^([^/]+)/([^/]+)/$', 'django.contrib.admin.views.main.change_list'), django/branches/multiple-db-support/django/contrib/auth/forms.py
r3502 r3523 5 5 from django.core import validators 6 6 from django import forms 7 8 class UserCreationForm(forms.Manipulator): 9 "A form that creates a user, with no privileges, from the given username and password." 10 def __init__(self): 11 self.fields = ( 12 forms.TextField(field_name='username', length=30, maxlength=30, is_required=True, 13 validator_list=[validators.isAlphaNumeric, self.isValidUsername]), 14 forms.PasswordField(field_name='password1', length=30, maxlength=60, is_required=True), 15 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 ) 18 19 def isValidUsername(self, field_data, all_data): 20 try: 21 User.objects.get(username=field_data) 22 except User.DoesNotExist: 23 return 24 raise validators.ValidationError, 'A user with that username already exists.' 25 26 def save(self, new_data): 27 "Creates the user." 28 return User.objects.create_user(new_data['username'], '', new_data['password1']) 7 29 8 30 class AuthenticationForm(forms.Manipulator): django/branches/multiple-db-support/django/core/management.py
r3502 r3523 830 830 except models.FieldDoesNotExist: 831 831 e.add(opts, '"admin.list_filter" refers to %r, which isn\'t a field.' % fn) 832 # date_hierarchy 833 if opts.admin.date_hierarchy: 834 try: 835 f = opts.get_field(opts.admin.date_hierarchy) 836 except models.FieldDoesNotExist: 837 e.add(opts, '"admin.date_hierarchy" refers to %r, which isn\'t a field.' % opts.admin.date_hierarchy) 832 838 833 839 # Check ordering attribute. django/branches/multiple-db-support/django/core/urlresolvers.py
r3502 r3523 131 131 132 132 class RegexURLResolver(object): 133 def __init__(self, regex, urlconf_name ):133 def __init__(self, regex, urlconf_name, default_kwargs=None): 134 134 # regex is a string representing a regular expression. 135 135 # urlconf_name is a string representing the module containing urlconfs. … … 137 137 self.urlconf_name = urlconf_name 138 138 self.callback = None 139 self.default_kwargs = default_kwargs or {} 139 140 140 141 def resolve(self, path): … … 150 151 else: 151 152 if sub_match: 152 return sub_match[0], sub_match[1], dict(match.groupdict(), **sub_match[2]) 153 sub_match_dict = dict(self.default_kwargs, **sub_match[2]) 154 return sub_match[0], sub_match[1], dict(match.groupdict(), **sub_match_dict) 153 155 tried.append(pattern.regex.pattern) 154 156 raise Resolver404, {'tried': tried, 'path': new_path} django/branches/multiple-db-support/django/db/backends/ansi/sql.py
r3387 r3523 138 138 table = opts.db_table 139 139 col = opts.get_field(f.rel.field_name).column 140 # For MySQL, r_name must be unique in the first 64 141 # characters. So we are careful with character usage here. 142 r_name = '%s_refs_%s_%x' % (r_col, col, 143 abs(hash((r_table, table)))) 140 144 sql = style.SQL_KEYWORD('ALTER TABLE') + ' %s ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s);' % \ 141 (quote_name(table), 142 quote_name('%s_referencing_%s_%s' % (r_col, r_table, col)), 145 (quote_name(table), quote_name(r_name), 143 146 quote_name(r_col), quote_name(r_table), quote_name(col)) 144 147 pending.setdefault(rel_class, []).append( django/branches/multiple-db-support/django/db/models/fields/__init__.py
r3502 r3523 290 290 return first_choice + list(self.choices) 291 291 rel_model = self.rel.to 292 return first_choice + [(x._get_pk_val(), str(x)) 293 for x in rel_model._default_manager.complex_filter(self.rel.limit_choices_to)] 292 if hasattr(self.rel, 'get_related_field'): 293 lst = [(getattr(x, self.rel.get_related_field().attname), str(x)) for x in rel_model._default_manager.complex_filter(self.rel.limit_choices_to)] 294 else: 295 lst = [(x._get_pk_val(), str(x)) for x in rel_model._default_manager.complex_filter(self.rel.limit_choices_to)] 296 return first_choice + lst 294 297 295 298 def get_choices_default(self): django/branches/multiple-db-support/django/db/models/fields/related.py
r3366 r3523 26 26 # Has the model already been loaded? 27 27 # If so, resolve the string reference right away 28 model = get_model(rel_cls._meta.app_label, field.rel.to)28 model = get_model(rel_cls._meta.app_label, field.rel.to, False) 29 29 if model: 30 30 field.rel.to = model django/branches/multiple-db-support/django/middleware/gzip.py
r3113 r3523 13 13 def process_response(self, request, response): 14 14 patch_vary_headers(response, ('Accept-Encoding',)) 15 if response.has_header('Content-Encoding'): 15 16 # Avoid gzipping if we've already got a content-encoding or if the 17 # content-type is Javascript (silly IE...) 18 is_js = "javascript" in response.headers.get('Content-Type', '').lower() 19 if response.has_header('Content-Encoding') or is_js: 16 20 return response 17 21 django/branches/multiple-db-support/docs/add_ons.txt
r3258 r3523 3 3 ===================== 4 4 5 Django aims to follow Python's "batteries included" philosophy. It ships with a 6 variety of extra, optional tools that solve common Web-development problems. 5 Django aims to follow Python's `"batteries included" philosophy`_. It ships 6 with a variety of extra, optional tools that solve common Web-development 7 problems. 7 8 8 9 This code lives in ``django/contrib`` in the Django distribution. Here's a 9 10 rundown of the packages in ``contrib``: 11 12 .. _"batteries included" philosophy: http://docs.python.org/tut/node12.html#batteries-included 10 13 11 14 admin django/branches/multiple-db-support/docs/db-api.txt
r3303 r3523 579 579 c = p.hometown # Hits the database. 580 580 581 Note that ``select_related()`` does not follow foreign keys that have 582 ``null=True``. 583 581 584 ``extra(select=None, where=None, params=None, tables=None)`` 582 585 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ django/branches/multiple-db-support/docs/faq.txt
r3502 r3523 621 621 ------------------------------------------------------------- 622 622 623 We don't recommend you create users via the admin interface, because at the 624 moment it requires you to edit password hashes manually. (Passwords are hashed 625 using one-way hash algorithms for security; there's currently no Web interface 626 for changing passwords by entering the actual password rather than the hash.) 627 628 To create a user, you'll have to use the Python API. See `creating users`_ for 629 full info. 623 If you'd like to use the admin site to create users, upgrade to the Django 624 development version, where this problem was fixed on Aug. 4, 2006. 625 626 You can also use the Python API. See `creating users`_ for full info. 630 627 631 628 .. _creating users: http://www.djangoproject.com/documentation/authentication/#creating-users django/branches/multiple-db-support/docs/url_dispatch.txt
r2818 r3523 264 264 265 265 urlpatterns = patterns('', 266 (r'^articles/(\d{4})/$', 'my project.news.views.year_archive'),267 (r'^articles/(\d{4})/(\d{2})/$', 'my project.news.views.month_archive'),268 (r'^articles/(\d{4})/(\d{2})/(\d+)/$', 'my project.news.views.article_detail'),269 ) 270 271 In this example, each view has a common prefix -- ``'my project.news.views'``.266 (r'^articles/(\d{4})/$', 'mysite.news.views.year_archive'), 267 (r'^articles/(\d{4})/(\d{2})/$', 'mysite.news.views.month_archive'), 268 (r'^articles/(\d{4})/(\d{2})/(\d+)/$', 'mysite.news.views.article_detail'), 269 ) 270 271 In this example, each view has a common prefix -- ``'mysite.news.views'``. 272 272 Instead of typing that out for each entry in ``urlpatterns``, you can use the 273 273 first argument to the ``patterns()`` function to specify a prefix to apply to … … 278 278 from django.conf.urls.defaults import * 279 279 280 urlpatterns = patterns('my project.news.views',280 urlpatterns = patterns('mysite.news.views', 281 281 (r'^articles/(\d{4})/$', 'year_archive'), 282 282 (r'^articles/(\d{4})/(\d{2})/$', 'month_archive'), … … 390 390 .. _generic views: http://www.djangoproject.com/documentation/generic_views/ 391 391 .. _syndication framework: http://www.djangoproject.com/documentation/syndication/ 392 393 Passing extra options to ``include()`` 394 -------------------------------------- 395 396 **New in the Django development version.** 397 398 Similarly, you can pass extra options to ``include()``. When you pass extra 399 options to ``include()``, *each* line in the included URLconf will be passed 400 the extra options. 401 402 For example, these two URLconf sets are functionally identical: 403 404 Set one:: 405 406 # main.py 407 urlpatterns = patterns('', 408 (r'^blog/', include('inner'), {'blogid': 3}), 409 ) 410 411 # inner.py 412 urlpatterns = patterns('', 413 (r'^archive/$', 'mysite.views.archive'), 414 (r'^about/$', 'mysite.views.about'), 415 ) 416 417 Set two:: 418 419 # main.py 420 urlpatterns = patterns('', 421 (r'^blog/', include('inner')), 422 ) 423 424 # inner.py 425 urlpatterns = patterns('', 426 (r'^archive/$', 'mysite.views.archive', {'blogid': 3}), 427 (r'^about/$', 'mysite.views.about', {'blogid': 3}), 428 ) 429 430 Note that extra options will *always* be passed to *every* line in the included 431 URLconf, regardless of whether the line's view actually accepts those options 432 as valid. For this reason, this technique is only useful if you're certain that 433 every view in the the included URLconf accepts the extra options you're passing.
