1
0
mirror of https://github.com/django/django.git synced 2025-07-04 09:49:12 +00:00

[multi-db] Merge trunk to [3825]. Some tests still failing. (previous commit was from tests/ dir only)

git-svn-id: http://code.djangoproject.com/svn/django/branches/multiple-db-support@4141 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jason Pellerin 2006-11-29 20:11:43 +00:00
parent 08fe1b64af
commit 9a01534370
20 changed files with 3207 additions and 870 deletions

View File

@ -151,8 +151,10 @@ answer newbie questions, and generally made Django that much better:
Milton Waddams Milton Waddams
Dan Watson <http://theidioteque.net/> Dan Watson <http://theidioteque.net/>
Rachel Willmer <http://www.willmer.com/kb/> Rachel Willmer <http://www.willmer.com/kb/>
Gary Wilson <gary.wilson@gmail.com>
wojtek wojtek
ye7cakf02@sneakemail.com ye7cakf02@sneakemail.com
ymasuda@ethercube.com
Cheng Zhang Cheng Zhang
A big THANK YOU goes to: A big THANK YOU goes to:

View File

@ -64,6 +64,7 @@ LANGUAGES = (
('sr', gettext_noop('Serbian')), ('sr', gettext_noop('Serbian')),
('sv', gettext_noop('Swedish')), ('sv', gettext_noop('Swedish')),
('ta', gettext_noop('Tamil')), ('ta', gettext_noop('Tamil')),
('tr', gettext_noop('Turkish')),
('uk', gettext_noop('Ukrainian')), ('uk', gettext_noop('Ukrainian')),
('zh-cn', gettext_noop('Simplified Chinese')), ('zh-cn', gettext_noop('Simplified Chinese')),
('zh-tw', gettext_noop('Traditional Chinese')), ('zh-tw', gettext_noop('Traditional Chinese')),

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -16,9 +16,26 @@ class ModPythonRequest(http.HttpRequest):
self.path = req.uri self.path = req.uri
def __repr__(self): def __repr__(self):
# Since this is called as part of error handling, we need to be very
# robust against potentially malformed input.
try:
get = pformat(self.GET)
except:
get = '<could not parse>'
try:
post = pformat(self.POST)
except:
post = '<could not parse>'
try:
cookies = pformat(self.COOKIES)
except:
cookies = '<could not parse>'
try:
meta = pformat(self.META)
except:
meta = '<could not parse>'
return '<ModPythonRequest\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % \ return '<ModPythonRequest\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % \
(self.path, pformat(self.GET), pformat(self.POST), pformat(self.COOKIES), (self.path, get, post, cookies, meta)
pformat(self.META))
def get_full_path(self): def get_full_path(self):
return '%s%s' % (self.path, self._req.args and ('?' + self._req.args) or '') return '%s%s' % (self.path, self._req.args and ('?' + self._req.args) or '')

View File

@ -78,9 +78,26 @@ class WSGIRequest(http.HttpRequest):
self.method = environ['REQUEST_METHOD'].upper() self.method = environ['REQUEST_METHOD'].upper()
def __repr__(self): def __repr__(self):
# Since this is called as part of error handling, we need to be very
# robust against potentially malformed input.
try:
get = pformat(self.GET)
except:
get = '<could not parse>'
try:
post = pformat(self.POST)
except:
post = '<could not parse>'
try:
cookies = pformat(self.COOKIES)
except:
cookies = '<could not parse>'
try:
meta = pformat(self.META)
except:
meta = '<could not parse>'
return '<WSGIRequest\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % \ return '<WSGIRequest\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % \
(pformat(self.GET), pformat(self.POST), pformat(self.COOKIES), (get, post, cookies, meta)
pformat(self.META))
def get_full_path(self): def get_full_path(self):
return '%s%s' % (self.path, self.environ.get('QUERY_STRING', '') and ('?' + self.environ.get('QUERY_STRING', '')) or '') return '%s%s' % (self.path, self.environ.get('QUERY_STRING', '') and ('?' + self.environ.get('QUERY_STRING', '')) or '')

View File

@ -13,7 +13,7 @@ from django.utils.translation import gettext, gettext_lazy, ngettext
from django.utils.functional import Promise, lazy from django.utils.functional import Promise, lazy
import re import re
_datere = r'(19|2\d)\d{2}-((?:0?[1-9])|(?:1[0-2]))-((?:0?[1-9])|(?:[12][0-9])|(?:3[0-1]))' _datere = r'\d{4}-\d{1,2}-\d{1,2}'
_timere = r'(?:[01]?[0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9])?' _timere = r'(?:[01]?[0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9])?'
alnum_re = re.compile(r'^\w+$') alnum_re = re.compile(r'^\w+$')
alnumurl_re = re.compile(r'^[-\w/]+$') alnumurl_re = re.compile(r'^[-\w/]+$')
@ -122,9 +122,29 @@ def isOnlyLetters(field_data, all_data):
if not field_data.isalpha(): if not field_data.isalpha():
raise ValidationError, gettext("Only alphabetical characters are allowed here.") raise ValidationError, gettext("Only alphabetical characters are allowed here.")
def _isValidDate(date_string):
"""
A helper function used by isValidANSIDate and isValidANSIDatetime to
check if the date is valid. The date string is assumed to already be in
YYYY-MM-DD format.
"""
from datetime import date
# Could use time.strptime here and catch errors, but datetime.date below
# produces much friendlier error messages.
year, month, day = map(int, date_string.split('-'))
# This check is needed because strftime is used when saving the date
# value to the database, and strftime requires that the year be >=1900.
if year < 1900:
raise ValidationError, gettext('Year must be 1900 or later.')
try:
date(year, month, day)
except ValueError, e:
raise ValidationError, gettext('Invalid date: %s.' % e)
def isValidANSIDate(field_data, all_data): def isValidANSIDate(field_data, all_data):
if not ansi_date_re.search(field_data): if not ansi_date_re.search(field_data):
raise ValidationError, gettext('Enter a valid date in YYYY-MM-DD format.') raise ValidationError, gettext('Enter a valid date in YYYY-MM-DD format.')
_isValidDate(field_data)
def isValidANSITime(field_data, all_data): def isValidANSITime(field_data, all_data):
if not ansi_time_re.search(field_data): if not ansi_time_re.search(field_data):
@ -133,6 +153,7 @@ def isValidANSITime(field_data, all_data):
def isValidANSIDatetime(field_data, all_data): def isValidANSIDatetime(field_data, all_data):
if not ansi_datetime_re.search(field_data): if not ansi_datetime_re.search(field_data):
raise ValidationError, gettext('Enter a valid date/time in YYYY-MM-DD HH:MM format.') raise ValidationError, gettext('Enter a valid date/time in YYYY-MM-DD HH:MM format.')
_isValidDate(field_data.split()[0])
def isValidEmail(field_data, all_data): def isValidEmail(field_data, all_data):
if not email_re.search(field_data): if not email_re.search(field_data):

View File

@ -286,7 +286,7 @@ class SchemaBuilder(object):
opts.object_name.lower())] opts.object_name.lower())]
for sql_file in sql_files: for sql_file in sql_files:
if os.path.exists(sql_file): if os.path.exists(sql_file):
fp = open(sql_file) fp = open(sql_file, 'U')
if backend.supports_compound_statements: if backend.supports_compound_statements:
output.append(BoundStatement(fp.read(), db.connection)) output.append(BoundStatement(fp.read(), db.connection))
else: else:

View File

@ -4,10 +4,18 @@ SQLite3 backend for django. Requires pysqlite2 (http://pysqlite.org/).
from django.db.backends import util from django.db.backends import util
try: try:
from pysqlite2 import dbapi2 as Database try:
from sqlite3 import dbapi2 as Database
except ImportError:
from pysqlite2 import dbapi2 as Database
except ImportError, e: except ImportError, e:
import sys
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "Error loading pysqlite2 module: %s" % e if sys.version_info < (2, 5, 0):
module = 'pysqlite2'
else:
module = 'sqlite3'
raise ImproperlyConfigured, "Error loading %s module: %s" % (module, e)
DatabaseError = Database.DatabaseError DatabaseError = Database.DatabaseError

View File

@ -2,7 +2,7 @@ from django.core import validators
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.utils.html import escape from django.utils.html import escape
from django.conf import settings from django.conf import settings
from django.utils.translation import gettext, gettext_lazy, ngettext from django.utils.translation import gettext, ngettext
FORM_FIELD_ID_PREFIX = 'id_' FORM_FIELD_ID_PREFIX = 'id_'
@ -343,7 +343,7 @@ class FormField(object):
def get_validation_errors(self, new_data): def get_validation_errors(self, new_data):
errors = {} errors = {}
if self.is_required and not new_data.get(self.field_name, False): if self.is_required and not new_data.get(self.field_name, False):
errors.setdefault(self.field_name, []).append(gettext_lazy('This field is required.')) errors.setdefault(self.field_name, []).append(gettext('This field is required.'))
return errors return errors
try: try:
for validator in self.validator_list: for validator in self.validator_list:

View File

@ -1319,13 +1319,16 @@ class DocTestRunner:
__LINECACHE_FILENAME_RE = re.compile(r'<doctest ' __LINECACHE_FILENAME_RE = re.compile(r'<doctest '
r'(?P<name>[\w\.]+)' r'(?P<name>[\w\.]+)'
r'\[(?P<examplenum>\d+)\]>$') r'\[(?P<examplenum>\d+)\]>$')
def __patched_linecache_getlines(self, filename): def __patched_linecache_getlines(self, filename, module_globals=None):
m = self.__LINECACHE_FILENAME_RE.match(filename) m = self.__LINECACHE_FILENAME_RE.match(filename)
if m and m.group('name') == self.test.name: if m and m.group('name') == self.test.name:
example = self.test.examples[int(m.group('examplenum'))] example = self.test.examples[int(m.group('examplenum'))]
return example.source.splitlines(True) return example.source.splitlines(True)
else: else:
return self.save_linecache_getlines(filename) if sys.version_info < (2, 5, 0):
return self.save_linecache_getlines(filename)
else:
return self.save_linecache_getlines(filename, module_globals)
def run(self, test, compileflags=None, out=None, clear_globs=True): def run(self, test, compileflags=None, out=None, clear_globs=True):
""" """

View File

@ -3,12 +3,11 @@ Iterator based sre token scanner
""" """
import sre_parse, sre_compile, sre_constants import sre_parse, sre_compile, sre_constants
from sre_constants import BRANCH, SUBPATTERN from sre_constants import BRANCH, SUBPATTERN
from sre import VERBOSE, MULTILINE, DOTALL
import re import re
__all__ = ['Scanner', 'pattern'] __all__ = ['Scanner', 'pattern']
FLAGS = (VERBOSE | MULTILINE | DOTALL) FLAGS = (re.VERBOSE | re.MULTILINE | re.DOTALL)
class Scanner(object): class Scanner(object):
def __init__(self, lexicon, flags=FLAGS): def __init__(self, lexicon, flags=FLAGS):
self.actions = [None] self.actions = [None]

View File

@ -4,7 +4,7 @@ from django.utils.html import escape
from django.http import HttpResponseServerError, HttpResponseNotFound from django.http import HttpResponseServerError, HttpResponseNotFound
import os, re import os, re
HIDDEN_SETTINGS = re.compile('SECRET|PASSWORD') HIDDEN_SETTINGS = re.compile('SECRET|PASSWORD|PROFANITIES_LIST')
def linebreak_iter(template_source): def linebreak_iter(template_source):
yield 0 yield 0

View File

@ -26,6 +26,7 @@ setup(
'media/js/*.js', 'media/js/*.js',
'media/js/admin/*js'], 'media/js/admin/*js'],
'django.contrib.comments': ['templates/comments/*.html'], 'django.contrib.comments': ['templates/comments/*.html'],
'django.contrib.sitemaps': ['templates/*.xml'],
}, },
scripts = ['django/bin/django-admin.py'], scripts = ['django/bin/django-admin.py'],
zip_safe = False, zip_safe = False,