diff options
| author | Georg Bauer <gb@hugo.westfalen.de> | 2005-11-03 21:29:48 +0000 |
|---|---|---|
| committer | Georg Bauer <gb@hugo.westfalen.de> | 2005-11-03 21:29:48 +0000 |
| commit | e27211a0deae2f1d402537f0ebb64ad4ccf6a4da (patch) | |
| tree | 73ba55f337e0d5c6e4ed39474ab6132879cc3947 /django | |
| parent | 9e724c25236b1e00a36a146e66b5deaa43d2af96 (diff) | |
| parent | cb45fd0ae20597306cd1f877efc99d9bd7cbee98 (diff) | |
i18n: merged to [1054] of trunkarchive/attic/i18n
git-svn-id: http://code.djangoproject.com/svn/django/branches/i18n@1067 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/db/__init__.py | 8 | ||||
| -rw-r--r-- | django/core/db/backends/ado_mssql.py | 4 | ||||
| -rw-r--r-- | django/core/db/backends/mysql.py | 11 | ||||
| -rw-r--r-- | django/core/db/backends/postgresql.py | 5 | ||||
| -rw-r--r-- | django/core/db/backends/sqlite3.py | 5 | ||||
| -rw-r--r-- | django/core/template/defaultfilters.py | 5 | ||||
| -rw-r--r-- | django/core/template/defaulttags.py | 13 | ||||
| -rw-r--r-- | django/middleware/sessions.py | 3 | ||||
| -rw-r--r-- | django/utils/cache.py | 14 | ||||
| -rw-r--r-- | django/utils/httpwrappers.py | 4 |
10 files changed, 49 insertions, 23 deletions
diff --git a/django/core/db/__init__.py b/django/core/db/__init__.py index c4f06e4c6e..6636d4f176 100644 --- a/django/core/db/__init__.py +++ b/django/core/db/__init__.py @@ -1,16 +1,11 @@ """ This is the core database connection. -All CMS code assumes database SELECT statements cast the resulting values as such: +All Django code assumes database SELECT statements cast the resulting values as such: * booleans are mapped to Python booleans * dates are mapped to Python datetime.date objects * times are mapped to Python datetime.time objects * timestamps are mapped to Python datetime.datetime objects - -Right now, we're handling this by using psycopg's custom typecast definitions. -If we move to a different database module, we should ensure that it either -performs the appropriate typecasting out of the box, or that it has hooks that -let us do that. """ from django.conf.settings import DATABASE_ENGINE @@ -41,6 +36,7 @@ get_limit_offset_sql = dbmod.get_limit_offset_sql get_random_function_sql = dbmod.get_random_function_sql get_table_list = dbmod.get_table_list get_relations = dbmod.get_relations +quote_name = dbmod.quote_name OPERATOR_MAPPING = dbmod.OPERATOR_MAPPING DATA_TYPES = dbmod.DATA_TYPES DATA_TYPES_REVERSE = dbmod.DATA_TYPES_REVERSE diff --git a/django/core/db/backends/ado_mssql.py b/django/core/db/backends/ado_mssql.py index 9ea0d5456d..a673c4812e 100644 --- a/django/core/db/backends/ado_mssql.py +++ b/django/core/db/backends/ado_mssql.py @@ -110,6 +110,10 @@ def get_table_list(cursor): def get_relations(cursor, table_name): raise NotImplementedError +def quote_name(name): + # TODO: Figure out how MS-SQL quotes database identifiers. + return name + OPERATOR_MAPPING = { 'exact': '=', 'iexact': 'LIKE', diff --git a/django/core/db/backends/mysql.py b/django/core/db/backends/mysql.py index 4399b6a6a0..e7ede84a12 100644 --- a/django/core/db/backends/mysql.py +++ b/django/core/db/backends/mysql.py @@ -122,18 +122,23 @@ def get_table_list(cursor): def get_relations(cursor, table_name): raise NotImplementedError +def quote_name(name): + if name.startswith("`") and name.endswith("`"): + return name # Quoting once is enough. + return "`%s`" % name + OPERATOR_MAPPING = { 'exact': '=', 'iexact': 'LIKE', - 'contains': 'LIKE', + 'contains': 'LIKE BINARY', 'icontains': 'LIKE', 'ne': '!=', 'gt': '>', 'gte': '>=', 'lt': '<', 'lte': '<=', - 'startswith': 'LIKE', - 'endswith': 'LIKE', + 'startswith': 'LIKE BINARY', + 'endswith': 'LIKE BINARY', 'istartswith': 'LIKE', 'iendswith': 'LIKE', } diff --git a/django/core/db/backends/postgresql.py b/django/core/db/backends/postgresql.py index c922fd42f6..a1de11e3df 100644 --- a/django/core/db/backends/postgresql.py +++ b/django/core/db/backends/postgresql.py @@ -116,6 +116,11 @@ def get_relations(cursor, table_name): continue return relations +def quote_name(name): + if name.startswith('"') and name.endswith('"'): + return name # Quoting once is enough. + return '"%s"' % name + # Register these custom typecasts, because Django expects dates/times to be # in Python's native (standard-library) datetime/time format, whereas psycopg # use mx.DateTime by default. diff --git a/django/core/db/backends/sqlite3.py b/django/core/db/backends/sqlite3.py index ea05302a61..3fde8c77e1 100644 --- a/django/core/db/backends/sqlite3.py +++ b/django/core/db/backends/sqlite3.py @@ -124,6 +124,11 @@ def get_table_list(cursor): def get_relations(cursor, table_name): raise NotImplementedError +def quote_name(name): + if name.startswith('"') and name.endswith('"'): + return name # Quoting once is enough. + return '"%s"' % name + # Operators and fields ######################################################## OPERATOR_MAPPING = { diff --git a/django/core/template/defaultfilters.py b/django/core/template/defaultfilters.py index 2604caf7f9..3a25add5e1 100644 --- a/django/core/template/defaultfilters.py +++ b/django/core/template/defaultfilters.py @@ -27,7 +27,10 @@ def floatformat(text, _): Displays a floating point number as 34.2 (with one decimal place) -- but only if there's a point to be displayed """ - f = float(text) + try: + f = float(text) + except ValueError: + return '' m = f - int(f) if m: return '%.1f' % f diff --git a/django/core/template/defaulttags.py b/django/core/template/defaulttags.py index bea4857dec..d7c53fe947 100644 --- a/django/core/template/defaulttags.py +++ b/django/core/template/defaulttags.py @@ -214,8 +214,12 @@ class SsiNode(Node): self.filepath, self.parsed = filepath, parsed def render(self, context): + from django.conf.settings import DEBUG if not include_is_allowed(self.filepath): - return '' # Fail silently for invalid includes. + if DEBUG: + return "[Didn't have permission to include file]" + else: + return '' # Fail silently for invalid includes. try: fp = open(self.filepath, 'r') output = fp.read() @@ -226,8 +230,11 @@ class SsiNode(Node): try: t = Template(output) return t.render(context) - except TemplateSyntaxError: - return '' # Fail silently for invalid included templates. + except (TemplateSyntaxError, e): + if DEBUG: + return "[Included template had syntax error: %s]" % e + else: + return '' # Fail silently for invalid included templates. return output class LoadNode(Node): diff --git a/django/middleware/sessions.py b/django/middleware/sessions.py index 42b2118410..8b9f21f78d 100644 --- a/django/middleware/sessions.py +++ b/django/middleware/sessions.py @@ -71,6 +71,7 @@ class SessionMiddleware: session_key = request.session.session_key or sessions.get_new_session_key() new_session = sessions.save(session_key, request.session._session, datetime.datetime.now() + datetime.timedelta(seconds=SESSION_COOKIE_AGE)) + expires = datetime.datetime.strftime(datetime.datetime.utcnow() + datetime.timedelta(seconds=SESSION_COOKIE_AGE), "%a, %d-%b-%Y %H:%M:%S GMT") response.set_cookie(SESSION_COOKIE_NAME, session_key, - max_age=SESSION_COOKIE_AGE, domain=SESSION_COOKIE_DOMAIN) + max_age=SESSION_COOKIE_AGE, expires=expires, domain=SESSION_COOKIE_DOMAIN) return response diff --git a/django/utils/cache.py b/django/utils/cache.py index ed6e3f11ea..b36753b558 100644 --- a/django/utils/cache.py +++ b/django/utils/cache.py @@ -22,19 +22,19 @@ from django.conf import settings from django.core.cache import cache cc_delim_re = re.compile(r'\s*,\s*') + def patch_cache_control(response, **kwargs): """ This function patches the Cache-Control header by adding all keyword arguments to it. The transformation is as follows: - - all keyword parameter names are turned to lowercase and - all _ will be translated to - - - if the value of a parameter is True (exatly True, not just a - true value), only the parameter name is added to the header - - all other parameters are added with their value, after applying - str to it. + * All keyword parameter names are turned to lowercase, and underscores + are converted to hyphens. + * If the value of a parameter is True (exactly True, not just a + true value), only the parameter name is added to the header. + * All other parameters are added with their value, after applying + str() to it. """ - def dictitem(s): t = s.split('=',1) if len(t) > 1: diff --git a/django/utils/httpwrappers.py b/django/utils/httpwrappers.py index 5f9362bd24..c1aa9d6ee1 100644 --- a/django/utils/httpwrappers.py +++ b/django/utils/httpwrappers.py @@ -172,9 +172,9 @@ class HttpResponse: return True return False - def set_cookie(self, key, value='', max_age=None, path='/', domain=None, secure=None): + def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=None): self.cookies[key] = value - for var in ('max_age', 'path', 'domain', 'secure'): + for var in ('max_age', 'path', 'domain', 'secure', 'expires'): val = locals()[var] if val is not None: self.cookies[key][var.replace('_', '-')] = val |
