magic-removal: Merged to [2136]

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2137 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-01-27 16:35:25 +00:00
parent 6dddef9b91
commit 1af3a39868
10 changed files with 34 additions and 9 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/python
from django.utils.translation import templateize
from django.utils.translation import templatize
import re
import os
import sys
@ -96,7 +96,7 @@ def make_messages():
thefile = file
if file.endswith('.html'):
src = open(os.path.join(dirpath, file), "rb").read()
open(os.path.join(dirpath, '%s.py' % file), "wb").write(templateize(src))
open(os.path.join(dirpath, '%s.py' % file), "wb").write(templatize(src))
thefile = '%s.py' % file
if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
cmd = 'xgettext %s -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy -o - "%s"' % (

View File

@ -110,6 +110,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
# 'django.core.context_processors.request',
)
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a

View File

@ -47,7 +47,7 @@ hr { clear:both; color:#eee; background-color:#eee; height:1px; border:none; mar
#footer { clear:both; padding:10px; }
/* COLUMN TYPES */
.colSM #content-main { float:right; }
.colSM #content-main { float:right; }
.colSM #content-related { float:left; }
.colMS #content-main, .colSM #content-main { width:68%; }
.colMS #content-related { margin-left:12px; width:30%; }
@ -170,6 +170,9 @@ fieldset.collapsed h2 { background-image:url(../img/admin/nav-bg.gif); backgroun
fieldset.collapsed .collapse-toggle { padding:3px 5px !important; background:#efefef; }
fieldset.collapsed .collapse-toggle a { display:inline !important; }
/* MONOSPACE TEXTAREAS */
fieldset.monospace textarea { font-family:"Bitstream Vera Sans Mono",Monaco,"Courier New",Courier,monospace; }
/* MESSAGES & ERRORS */
ul.messagelist { padding:0 0 5px 0; margin:0; }
ul.messagelist li { font-size:12px; display:block; padding:4px 5px 4px 25px; margin:0 0 3px 0; border-bottom:1px solid #ddd; color:#666; background:#ffc url(../img/admin/icon_success.gif) 5px .3em no-repeat; }

View File

@ -1,6 +1,6 @@
{% extends "admin/base_site" %}
{% load i18n %}
{% block userlinks %}<a href="../doc/">{% trans 'Documentation' %}</a> / {% trans 'Change password' %} / <a href="../logout/">{% trans 'Log out' %}</a>{% endblock %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password change' %}</div>{% endblock %}
{% block title %}{% trans 'Password change' %}{% endblock %}

View File

@ -38,6 +38,9 @@ def i18n(request):
context_extras['LANGUAGE_CODE'] = settings.LANGUAGE_CODE
return context_extras
def request(request):
return {'request': request}
# PermWrapper and PermLookupDict proxy the permissions system into objects that
# the template system can understand.

View File

@ -13,7 +13,7 @@ from django.utils.translation import gettext, gettext_lazy, ngettext
from django.utils.functional import Promise, lazy
import re
_datere = r'\d{4}-((?:0?[1-9])|(?:1[0-2]))-((?:0?[1-9])|(?:[12][0-9])|(?:3[0-1]))'
_datere = r'(19|2\d)\d{2}-((?:0?[1-9])|(?:1[0-2]))-((?:0?[1-9])|(?:[12][0-9])|(?:3[0-1]))'
_timere = r'(?:[01]?[0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9])?'
alnum_re = re.compile(r'^\w+$')
alnumurl_re = re.compile(r'^[\w/]+$')

View File

@ -369,7 +369,7 @@ dot_re = re.compile(r'\S')
def blankout(src, char):
"""
Changes every non-whitespace character to the given char.
Used in the templateize function.
Used in the templatize function.
"""
return dot_re.sub(char, src)
@ -378,7 +378,7 @@ block_re = re.compile(r"""^\s*blocktrans(?:\s+|$)""")
endblock_re = re.compile(r"""^\s*endblocktrans$""")
plural_re = re.compile(r"""^\s*plural$""")
constant_re = re.compile(r"""_\(((?:".*?")|(?:'.*?'))\)""")
def templateize(src):
def templatize(src):
"""
Turns a Django template into something that is understood by xgettext. It
does so by translating the Django translation tags into standard gettext

View File

@ -110,8 +110,8 @@ This sends a message to john@example.com and jane@example.com, with them both
receiving a separate e-mail::
datatuple = (
('Subject', 'Message.', 'from@example.com', ['john@example.com'],
('Subject', 'Message.', 'from@example.com', ['jane@example.com'],
('Subject', 'Message.', 'from@example.com', ['john@example.com']),
('Subject', 'Message.', 'from@example.com', ['jane@example.com']),
)
send_mass_mail(datatuple)

View File

@ -419,6 +419,14 @@ How do I limit admin access so that objects can only be edited by the users who
See the answer to the previous question.
My admin-site CSS and images showed up fine using the development server, but they're not displaying when using mod_python.
---------------------------------------------------------------------------------------------------------------------------
See `serving the admin files`_ in the "How to use Django with mod_python"
documentation.
.. _serving the admin files: http://www.djangoproject.com/documentation/modpython/#serving-the-admin-files
My "list_filter" contains a ManyToManyField, but the filter doesn't display.
----------------------------------------------------------------------------

View File

@ -335,6 +335,16 @@ See the `internationalization docs`_ for more.
.. _LANGUAGE_CODE setting: http://www.djangoproject.com/documentation/settings/#language-code
.. _internationalization docs: http://www.djangoproject.com/documentation/i18n/
django.core.context_processors.request
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**New in Django development version**
If ``TEMPLATE_CONTEXT_PROCESSORS`` contains this processor, every
``DjangoContext`` will contain a variable ``request``, which is the current
`HttpRequest object`_. Note that this processor is not enabled by default;
you'll have to activate it.
Loading templates
-----------------