Django

Code

Changeset 869

Show
Ignore:
Timestamp:
10/14/05 16:33:45 (3 years ago)
Author:
hugo
Message:

i18n: merged up to r868

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/i18n/django/conf/global_settings.py

    r815 r869  
    6060DATABASE_USER = '' 
    6161DATABASE_PASSWORD = '' 
    62 DATABASE_HOST = ''             # Set to empty string for localhost 
     62DATABASE_HOST = ''             # Set to empty string for localhost. 
     63DATABASE_PORT = ''             # Set to empty string for default. 
    6364 
    6465# Host for sending e-mail. 
  • django/branches/i18n/django/conf/project_template/settings/main.py

    r512 r869  
    1616DATABASE_PASSWORD = ''         # Not used with sqlite3. 
    1717DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3. 
     18DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3. 
    1819 
    1920SITE_ID = 1 
  • django/branches/i18n/django/core/db/backends/mysql.py

    r853 r869  
    5454 
    5555    def cursor(self): 
    56         from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PASSWORD, DEBUG 
     56        from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, DEBUG 
    5757        if self.connection is None: 
    58             self.connection = Database.connect(user=DATABASE_USER, db=DATABASE_NAME, 
    59                 passwd=DATABASE_PASSWORD, host=DATABASE_HOST, conv=django_conversions) 
     58            kwargs = { 
     59                'user': DATABASE_USER, 
     60                'db': DATABASE_NAME, 
     61                'passwd': DATABASE_PASSWORD, 
     62                'host': DATABASE_HOST, 
     63                'conv': django_conversions, 
     64            } 
     65            if DATABASE_PORT: 
     66                kwargs['port'] = DATABASE_PORT 
     67            self.connection = Database.connect(**kwargs) 
    6068        if DEBUG: 
    6169            return base.CursorDebugWrapper(MysqlDebugWrapper(self.connection.cursor()), self) 
  • django/branches/i18n/django/core/db/backends/postgresql.py

    r853 r869  
    1616 
    1717    def cursor(self): 
    18         from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PASSWORD, DEBUG, TIME_ZONE 
     18        from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, DEBUG, TIME_ZONE 
    1919        if self.connection is None: 
    2020            if DATABASE_NAME == '': 
     
    2828            if DATABASE_HOST: 
    2929                conn_string += " host=%s" % DATABASE_HOST 
     30            if DATABASE_PORT: 
     31                conn_string += " port=%s" % DATABASE_PORT 
    3032            self.connection = Database.connect(conn_string) 
    3133            self.connection.set_isolation_level(1) # make transactions transparent to all cursors 
  • django/branches/i18n/django/core/extensions.py

    r850 r869  
    33# for convenience's sake. 
    44 
    5 from django.core import template_loader 
    65from django.core.exceptions import Http404, ObjectDoesNotExist 
    7 from django.core.template import Context 
     6from django.core.template import Context, loader 
    87from django.conf.settings import DEBUG, INTERNAL_IPS 
    98from django.utils.httpwrappers import HttpResponse 
    109 
    1110def render_to_response(*args, **kwargs): 
    12     return HttpResponse(template_loader.render_to_string(*args, **kwargs)) 
     11    return HttpResponse(loader.render_to_string(*args, **kwargs)) 
    1312load_and_render = render_to_response # For backwards compatibility. 
    1413 
  • django/branches/i18n/django/core/rss.py

    r775 r869  
    1 from django.core import template_loader 
    21from django.core.exceptions import ObjectDoesNotExist 
    3 from django.core.template import Context 
     2from django.core.template import Context, loader 
    43from django.models.core import sites 
    54from django.utils import feedgenerator 
     
    2928        get_list_kwargs_cb -- Function that takes the param and returns a 
    3029        dictionary to use in addition to get_list_kwargs (if applicable). 
    31          
     30 
    3231        get_pubdate_cb -- Function that takes the object and returns a datetime 
    3332        to use as the publication date in the feed. 
     
    5049        self.enc_length = enc_length 
    5150        self.enc_mime_type = enc_mime_type 
    52          
     51 
    5352    def get_feed(self, param_slug=None): 
    5453        """ 
     
    6564        current_site = sites.get_current() 
    6665        f = self._get_feed_generator_object(param) 
    67         title_template = template_loader.get_template('rss/%s_title' % self.slug) 
    68         description_template = template_loader.get_template('rss/%s_description' % self.slug) 
     66        title_template = loader.get_template('rss/%s_title' % self.slug) 
     67        description_template = loader.get_template('rss/%s_description' % self.slug) 
    6968        kwargs = self.get_list_kwargs.copy() 
    7069        if param and self.get_list_kwargs_cb: 
     
    103102            ) 
    104103        return f 
    105          
     104 
    106105    def _get_feed_generator_object(self, param): 
    107106        current_site = sites.get_current() 
  • django/branches/i18n/django/core/template_loader.py

    r717 r869  
    1 "Wrapper for loading templates from storage of some sort (e.g. files or db)" 
    2 import template 
    3 from template_file import load_template_source 
     1# This module is DEPRECATED! 
     2
     3# You should no longer be using django.core.template_loader. 
     4
     5# Use django.core.template.loader instead. 
    46 
    5 class ExtendsError(Exception): 
    6     pass 
    7  
    8 def get_template(template_name): 
    9     """ 
    10     Returns a compiled template.Template object for the given template name, 
    11     handling template inheritance recursively. 
    12     """ 
    13     return get_template_from_string(load_template_source(template_name)) 
    14  
    15 def get_template_from_string(source): 
    16     """ 
    17     Returns a compiled template.Template object for the given template code, 
    18     handling template inheritance recursively. 
    19     """ 
    20     return template.Template(source) 
    21  
    22 def render_to_string(template_name, dictionary=None, context_instance=None): 
    23     """ 
    24     Loads the given template_name and renders it with the given dictionary as 
    25     context. The template_name may be a string to load a single template using 
    26     get_template, or it may be a tuple to use select_template to find one of 
    27     the templates in the list.  Returns a string.  
    28     """ 
    29     dictionary = dictionary or {} 
    30     if isinstance(template_name, (list, tuple)): 
    31         t = select_template(template_name) 
    32     else: 
    33         t = get_template(template_name) 
    34     if context_instance: 
    35         context_instance.update(dictionary) 
    36     else: 
    37         context_instance = template.Context(dictionary) 
    38     return t.render(context_instance) 
    39  
    40 def select_template(template_name_list): 
    41     "Given a list of template names, returns the first that can be loaded." 
    42     for template_name in template_name_list: 
    43         try: 
    44             return get_template(template_name) 
    45         except template.TemplateDoesNotExist: 
    46             continue 
    47     # If we get here, none of the templates could be loaded 
    48     raise template.TemplateDoesNotExist, ', '.join(template_name_list) 
    49  
    50 class BlockNode(template.Node): 
    51     def __init__(self, name, nodelist, parent=None): 
    52         self.name, self.nodelist, self.parent = name, nodelist, parent 
    53  
    54     def __repr__(self): 
    55         return "<Block Node: %s. Contents: %r>" % (self.name, self.nodelist) 
    56  
    57     def render(self, context): 
    58         context.push() 
    59         # Save context in case of block.super(). 
    60         self.context = context 
    61         context['block'] = self 
    62         result = self.nodelist.render(context) 
    63         context.pop() 
    64         return result 
    65  
    66     def super(self): 
    67         if self.parent: 
    68             return self.parent.render(self.context) 
    69         return '' 
    70  
    71     def add_parent(self, nodelist): 
    72         if self.parent: 
    73             self.parent.add_parent(nodelist) 
    74         else: 
    75             self.parent = BlockNode(self.name, nodelist) 
    76  
    77 class ExtendsNode(template.Node): 
    78     def __init__(self, nodelist, parent_name, parent_name_var, template_dirs=None): 
    79         self.nodelist = nodelist 
    80         self.parent_name, self.parent_name_var = parent_name, parent_name_var 
    81         self.template_dirs = template_dirs 
    82  
    83     def get_parent(self, context): 
    84         if self.parent_name_var: 
    85             self.parent_name = template.resolve_variable_with_filters(self.parent_name_var, context) 
    86         parent = self.parent_name 
    87         if not parent: 
    88             error_msg = "Invalid template name in 'extends' tag: %r." % parent 
    89             if self.parent_name_var: 
    90                 error_msg += " Got this from the %r variable." % self.parent_name_var 
    91             raise template.TemplateSyntaxError, error_msg 
    92         try: 
    93             return get_template_from_string(load_template_source(parent, self.template_dirs)) 
    94         except template.TemplateDoesNotExist: 
    95             raise template.TemplateSyntaxError, "Template %r cannot be extended, because it doesn't exist" % parent 
    96  
    97     def render(self, context): 
    98         compiled_parent = self.get_parent(context) 
    99         parent_is_child = isinstance(compiled_parent.nodelist[0], ExtendsNode) 
    100         parent_blocks = dict([(n.name, n) for n in compiled_parent.nodelist.get_nodes_by_type(BlockNode)]) 
    101         for block_node in self.nodelist.get_nodes_by_type(BlockNode): 
    102             # Check for a BlockNode with this node's name, and replace it if found. 
    103             try: 
    104                 parent_block = parent_blocks[block_node.name] 
    105             except KeyError: 
    106                 # This BlockNode wasn't found in the parent template, but the 
    107                 # parent block might be defined in the parent's *parent*, so we 
    108                 # add this BlockNode to the parent's ExtendsNode nodelist, so 
    109                 # it'll be checked when the parent node's render() is called. 
    110                 if parent_is_child: 
    111                     compiled_parent.nodelist[0].nodelist.append(block_node) 
    112             else: 
    113                 # Keep any existing parents and add a new one. Used by BlockNode. 
    114                 parent_block.parent = block_node.parent 
    115                 parent_block.add_parent(parent_block.nodelist) 
    116                 parent_block.nodelist = block_node.nodelist 
    117         return compiled_parent.render(context) 
    118  
    119 def do_block(parser, token): 
    120     """ 
    121     Define a block that can be overridden by child templates. 
    122     """ 
    123     bits = token.contents.split() 
    124     if len(bits) != 2: 
    125         raise template.TemplateSyntaxError, "'%s' tag takes only one argument" % bits[0] 
    126     block_name = bits[1] 
    127     # Keep track of the names of BlockNodes found in this template, so we can 
    128     # check for duplication. 
    129     try: 
    130         if block_name in parser.__loaded_blocks: 
    131             raise template.TemplateSyntaxError, "'%s' tag with name '%s' appears more than once" % (bits[0], block_name) 
    132         parser.__loaded_blocks.append(block_name) 
    133     except AttributeError: # parser._loaded_blocks isn't a list yet 
    134         parser.__loaded_blocks = [block_name] 
    135     nodelist = parser.parse(('endblock',)) 
    136     parser.delete_first_token() 
    137     return BlockNode(block_name, nodelist) 
    138  
    139 def do_extends(parser, token): 
    140     """ 
    141     Signal that this template extends a parent template. 
    142  
    143     This tag may be used in two ways: ``{% extends "base" %}`` (with quotes) 
    144     uses the literal value "base" as the name of the parent template to extend, 
    145     or ``{% entends variable %}`` uses the value of ``variable`` as the name 
    146     of the parent template to extend. 
    147     """ 
    148     bits = token.contents.split() 
    149     if len(bits) != 2: 
    150         raise template.TemplateSyntaxError, "'%s' takes one argument" % bits[0] 
    151     parent_name, parent_name_var = None, None 
    152     if (bits[1].startswith('"') and bits[1].endswith('"')) or (bits[1].startswith("'") and bits[1].endswith("'")): 
    153         parent_name = bits[1][1:-1] 
    154     else: 
    155         parent_name_var = bits[1] 
    156     nodelist = parser.parse() 
    157     if nodelist.get_nodes_by_type(ExtendsNode): 
    158         raise template.TemplateSyntaxError, "'%s' cannot appear more than once in the same template" % bits[0] 
    159     return ExtendsNode(nodelist, parent_name, parent_name_var) 
    160  
    161 template.register_tag('block', do_block) 
    162 template.register_tag('extends', do_extends) 
     7from django.core.template.loader import * 
  • django/branches/i18n/django/middleware/admin.py

    r669 r869  
    11from django.utils import httpwrappers 
    2 from django.core import template_loader 
    3 from django.core.extensions import DjangoContext as Context 
     2from django.core.extensions import DjangoContext 
     3from django.core.extensions import render_to_response 
    44from django.models.auth import users 
    55from django.views.registration import passwords 
     
    9797        else: 
    9898            post_data = encode_post_data({}) 
    99         t = template_loader.get_template(self.get_login_template_name()) 
    100         c = Context(request, { 
     99        return render_to_response(self.get_login_template_name(), { 
    101100            'title': 'Log in', 
    102101            'app_path': request.path, 
    103102            'post_data': post_data, 
    104103            'error_message': error_message 
    105         }) 
    106         return httpwrappers.HttpResponse(t.render(c)) 
     104        }, context_instance=DjangoContext(request)) 
    107105 
    108106    def authenticate_user(self, user, password): 
  • django/branches/i18n/django/views/admin/doc.py

    r665 r869  
    55from django.core.extensions import DjangoContext, render_to_response 
    66from django.core.exceptions import Http404, ViewDoesNotExist 
    7 from django.core import template, template_loader, defaulttags, defaultfilters, urlresolvers 
     7from django.core import template, template_loader, urlresolvers 
     8from django.core.template import defaulttags, defaultfilters 
    89try: 
    910    from django.parts.admin import doc 
  • django/branches/i18n/django/views/admin/template.py

    r675 r869  
    1 from django.core import formfields, template_loader, validators 
     1from django.core import formfields, validators 
    22from django.core import template 
     3from django.core.template import loader 
    34from django.core.extensions import DjangoContext, render_to_response 
    45from django.models.core import sites 
     
    5051        # for "extends" that uses the site's TEMPLATE_DIR instead 
    5152        def new_do_extends(parser, token): 
    52             node = template_loader.do_extends(parser, token) 
     53            node = loader.do_extends(parser, token) 
    5354            node.template_dirs = settings_module.TEMPLATE_DIRS 
    5455            return node 
     
    5960        error = None 
    6061        try: 
    61             tmpl = template_loader.get_template_from_string(field_data) 
     62            tmpl = loader.get_template_from_string(field_data) 
    6263            tmpl.render(template.Context({})) 
    6364        except template.TemplateSyntaxError, e: 
    6465            error = e 
    65         template.register_tag('extends', template_loader.do_extends) 
     66        template.register_tag('extends', loader.do_extends) 
    6667        if error: 
    6768            raise validators.ValidationError, e.args 
  • django/branches/i18n/django/views/auth/login.py

    r669 r869  
    11from django.parts.auth.formfields import AuthenticationForm 
    2 from django.core import formfields, template_loader 
     2from django.core import formfields 
    33from django.core.extensions import DjangoContext, render_to_response 
    44from django.models.auth import users 
  • django/branches/i18n/django/views/defaults.py

    r549 r869  
    1 from django.core import template_loader 
    21from django.core.exceptions import Http404, ObjectDoesNotExist 
    3 from django.core.template import Context 
     2from django.core.template import Context, loader 
    43from django.models.core import sites 
    54from django.utils import httpwrappers 
     
    5756            return httpwrappers.HttpResponseGone() 
    5857        return httpwrappers.HttpResponseRedirect(r.new_path) 
    59     t = template_loader.get_template('404') 
     58    t = loader.get_template('404') 
    6059    c = Context() 
    6160    return httpwrappers.HttpResponseNotFound(t.render(c)) 
     
    6867    Context: None 
    6968    """ 
    70     t = template_loader.get_template('500') 
     69    t = loader.get_template('500') 
    7170    c = Context() 
    7271    return httpwrappers.HttpResponseServerError(t.render(c)) 
  • django/branches/i18n/django/views/registration/passwords.py

    r665 r869  
    1 from django.core import formfields, template_loader, validators 
     1from django.core import formfields, validators 
    22from django.core.extensions import DjangoContext, render_to_response 
     3from django.core.template import loader 
    34from django.models.auth import users 
    45from django.views.decorators.auth import login_required 
     
    3334        else: 
    3435            site_name = domain = domain_override 
    35         t = template_loader.get_template('registration/password_reset_email') 
     36        t = loader.get_template('registration/password_reset_email') 
    3637        c = { 
    3738            'new_password': new_pass, 
  • django/branches/i18n/docs/forms.txt

    r610 r869  
    6666POSTed data from the browser and creates a new ``Place`` object:: 
    6767 
    68     from django.core import template_loader 
    6968    from django.core.exceptions import Http404 
    70     from django.core.extensions import DjangoContext as Context 
     69    from django.core.extensions import render_to_response 
    7170    from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect 
    7271    from django.models.places import places 
     
    113112        # the last two arguments to FormWrapper for now. 
    114113        form = formfields.FormWrapper(places.AddManipulator(), {}, {}) 
    115  
    116         # Create a template, context and response. 
    117         t = template_loader.get_template('places/naive_create_form') 
    118         c = Context(request, { 
    119             'form': form 
    120         }) 
    121         return HttpResponse(t.render(c)) 
     114        return render_to_response('places/naive_create_form', {'form': form}) 
    122115 
    123116(This view, as well as all the following ones, has the same imports as in the 
     
    170163        errors = manipulator.get_validation_errors(new_data) 
    171164        if errors: 
    172             t = template_loader.get_template('places/errors') 
    173             c = Context(request, { 
    174                 'errors': errors 
    175             } 
    176             return HttpResponse(t.render(c)) 
     165            return render_to_response('places/errors', {'errors': errors}) 
    177166        else: 
    178167            manipulator.do_html2python(request.POST) 
     
    246235        # Create the FormWrapper, template, context, response. 
    247236        form = formfields.FormWrapper(manipulator, new_data, errors) 
    248         t = template_loader.get_template("places/create_form") 
    249         c = Context(request, { 
    250             'form': form, 
    251         }) 
    252         return HttpResponse(t.render(c)) 
     237        return render_to_response('places/create_form', {'form': form}) 
    253238 
    254239and here's the ``create_form`` template:: 
     
    339324 
    340325        form = formfields.FormWrapper(manipulator, new_data, errors) 
    341         t = template_loader.get_template("places/edit_form") 
    342         c = Context(request, { 
    343             'form': form, 
    344             'place': place, 
    345         }) 
    346         return HttpResponse(t.render(c)) 
     326        return render_to_response('places/edit_form', {'form': form, 'place': place}) 
    347327 
    348328The only real differences are: 
     
    423403            errors = new_data = {} 
    424404        form = formfields.FormWrapper(manipulator, new_data, errors) 
    425         t = template_loader.get_template("contact_form") 
    426         c = Context(request, { 
    427             'form': form, 
    428         }) 
    429         return HttpResponse(t.render(c)) 
     405        return render_to_response('contact_form', {'form': form}) 
    430406 
    431407Validators 
  • django/branches/i18n/docs/sessions.txt

    r669 r869  
    137137                return HttpResponse("Please enable cookies and try again.") 
    138138        request.session.set_test_cookie() 
    139         t = template_loader.get_template("foo/login_form") 
    140         c = Context(request) 
    141         return HttpResponse(t.render(c)) 
     139        return render_to_response('foo/login_form') 
    142140 
    143141Using sessions out of views 
  • django/branches/i18n/docs/templates_python.txt

    r775 r869  
    308308Django has two ways to load templates from files: 
    309309 
    310 ``django.core.template_loader.get_template(template_name)`` 
     310``django.core.template.loader.get_template(template_name)`` 
    311311    ``get_template`` returns the compiled template (a ``Template`` object) for 
    312312    the template with the given name. If the template doesn't exist, it raises 
    313313    ``django.core.template.TemplateDoesNotExist``. 
    314314 
    315 ``django.core.template_loader.select_template(template_name_list)`` 
     315``django.core.template.loader.select_template(template_name_list)`` 
    316316    ``select_template`` is just like ``get_template``, except it takes a list 
    317317    of template names. Of the list, it returns the first template that exists. 
     
    399399 
    400400    For a ton of examples, read the source code for Django's default filters 
    401     and tags. They're in ``django/core/defaultfilters.py`` and 
    402     ``django/core/defaulttags.py``, respectively. 
     401    and tags. They're in ``django/core/template/defaultfilters.py`` and 
     402    ``django/core/template/defaulttags.py``, respectively. 
    403403 
    404404Writing custom template filters 
     
    711711For more examples of complex rendering, see the source code for ``{% if %}``, 
    712712``{% for %}``, ``{% ifequal %}`` and ``{% ifchanged %}``. They live in 
    713 ``django/core/defaulttags.py``. 
     713``django/core/template/defaulttags.py``. 
  • django/branches/i18n/docs/templates.txt

    r775 r869  
    377377        ``forloop.counter``         The current iteration of the loop (1-indexed) 
    378378        ``forloop.counter0``        The current iteration of the loop (0-indexed) 
    379         ``forloop.revcounter``      The number of iterations from the end of the  
     379        ``forloop.revcounter``      The number of iterations from the end of the 
    380380                                    loop (1-indexed) 
    381         ``forloop.revcounter0``     The number of iterations from the end of the  
     381        ``forloop.revcounter0``     The number of iterations from the end of the 
    382382                                    loop (0-indexed) 
    383383        ``forloop.first``           True if this is the first time through the loop 
     
    570570 
    571571``add`` 
    572     Adds the arg to the value 
     572    Adds the arg to the value. 
    573573 
    574574``addslashes`` 
    575     Adds slashes - useful for passing strings to JavaScript, for example. 
     575    Adds slashes. Useful for passing strings to JavaScript, for example. 
    576576 
    577577``capfirst`` 
    578     Capitalizes the first character of the value 
     578    Capitalizes the first character of the value. 
    579579 
    580580``center`` 
    581     Centers the value in a field of a given width 
     581    Centers the value in a field of a given width. 
    582582 
    583583``cut`` 
    584     Removes all values of arg from the given string 
     584    Removes all values of arg from the given string. 
    585585 
    586586``date`` 
    587     Formats a date according to the given format (same as the ``now`` tag) 
     587    Formats a date according to the given format (same as the ``now`` tag). 
    588588 
    589589``default`` 
    590     If value is unavailable, use given default 
     590    If value is unavailable, use given default. 
     591 
     592``default_if_none`` 
     593    If value is ``None``, use given default. 
    591594 
    592595``dictsort`` 
     
    599602 
    600603``divisibleby`` 
    601     Returns true if the value is divisible by the argument 
     604    Returns true if the value is divisible by the argument. 
    602605 
    603606``escape`` 
    604     Escapes a string's HTML 
     607    Escapes a string's HTML. 
    605608 
    606609``filesizeformat`` 
     
    609612 
    610613``first`` 
    611     Returns the first item in a list 
     614    Returns the first item in a list. 
    612615 
    613616``fix_ampersands`` 
    614     Replaces ampersands with ``&amp;`` entities 
     617    Replaces ampersands with ``&amp;`` entities. 
    615618 
    616619``floatformat`` 
    617620    Displays a floating point number as 34.2 (with one decimal places) - but 
    618     only if there's a point to be displayed 
     621    only if there's a point to be displayed. 
    619622 
    620623``get_digit`` 
     
    625628 
    626629``join`` 
    627     Joins a list with a string, like Python's ``str.join(list)`` 
     630    Joins a list with a string, like Python's ``str.join(list)``. 
    628631 
    629632``length`` 
    630     Returns the length of the value - useful for lists 
     633    Returns the length of the value. Useful for lists. 
    631634 
    632635``length_is`` 
    633     Returns a boolean of whether the value's length is the argument 
     636    Returns a boolean of whether the value's length is the argument. 
    634637 
    635638``linebreaks`` 
    636     Converts newlines into <p> and <br />s 
     639    Converts newlines into <p> and <br />s. 
    637640 
    638641``linebreaksbr`` 
    639     Converts newlines into <br />s 
     642    Converts newlines into <br />s. 
    640643 
    641644``linenumbers`` 
    642     Displays text with line numbers 
     645    Displays text with line numbers. 
    643646 
    644647``ljust`` 
    645     Left-aligns the value in a field of a given width 
     648    Left-aligns the value in a field of a given width. 
    646649 
    647650    **Argument:** field size 
    648651 
    649652``lower`` 
    650     Converts a string into all lowercase 
     653    Converts a string into all lowercase. 
    651654 
    652655``make_list`` 
     
    655658 
    656659``phone2numeric`` 
    657     Takes a phone number and converts it in to its numerical equivalent 
     660    Takes a phone number and converts it in to its numerical equivalent. 
    658661 
    659662``pluralize`` 
    660     Returns 's' if the value is not 1, for '1 vote' vs. '2 votes' 
     663    Returns 's' if the value is not 1, for '1 vote' vs. '2 votes'. 
    661664 
    662665``pprint`` 
    663     A wrapper around pprint.pprint -- for debugging, really 
     666    A wrapper around pprint.pprint -- for debugging, really. 
    664667 
    665668``random`` 
    666     Returns a random item from the list 
     669    Returns a random item from the list. 
    667670 
    668671``removetags`` 
    669     Removes a space separated list of [X]HTML tags from the output 
     672    Removes a space separated list of [X]HTML tags from the output. 
    670673 
    671674``rjust`` 
    672     Right-aligns the value in a field of a given width 
     675    Right-aligns the value in a field of a given width. 
    673676 
    674677    **Argument:** field size 
     
    697700 
    698701``striptags`` 
    699     Strips all [X]HTML tags 
     702    Strips all [X]HTML tags. 
    700703 
    701704``time`` 
     
    703706 
    704707``timesince`` 
    705     Formats a date as the time since that date (i.e. "4 days, 6 hours") 
     708    Formats a date as the time since that date (i.e. "4 days, 6 hours"). 
    706709 
    707710``title`` 
    708     Converts a string into titlecase 
     711    Converts a string into titlecase. 
    709712 
    710713``truncatewords`` 
    711     Truncates a string after a certain number of words 
     714    Truncates a string after a certain number of words. 
    712715 
    713716    **Argument:** Number of words to truncate after 
     
    734737 
    735738``upper`` 
    736     Converts a string into all uppercase 
     739    Converts a string into all uppercase. 
    737740 
    738741``urlencode`` 
    739     Escapes a value for use in a URL 
     742    Escapes a value for use in a URL. 
    740743 
    741744``urlize`` 
    742     Converts URLs in plain text into clickable links 
     745    Converts URLs in plain text into clickable links. 
    743746 
    744747``urlizetrunc`` 
    745     Converts URLs into clickable links, truncating URLs to the given character limit 
    746  
    747     **Argument:** Length to truncate URLs to. 
     748    Converts URLs into clickable links, truncating URLs to the given character 
     749    limit. 
     750 
     751    **Argument:** Length to truncate URLs to 
    748752 
    749753``wordcount`` 
    750     Returns the number of words 
     754    Returns the number of words. 
    751755 
    752756``wordwrap`` 
    753     Wraps words at specified line length 
    754  
    755     **Argument:** number of words to wrap the text at. 
     757    Wraps words at specified line length. 
     758 
     759    **Argument:** number of words at which to wrap the text 
    756760 
    757761``yesno`` 
  • django/branches/i18n/docs/tutorial03.txt

    r775 r869  
    192192So let's use Django's template system to separate the design from Python:: 
    193193 
    194     from django.core import template_loader 
    195     from django.core.template import Context 
     194    from django.core.template import Context, loader 
    196195    from django.models.polls import polls 
    197196    from django.utils.httpwrappers import HttpResponse 
     
    199198    def index(request): 
    200199        latest_poll_list = polls.get_list(order_by=['-pub_date'], limit=5) 
    201         t = template_loader.get_template('polls/index') 
     200        t = loader.get_template('polls/index') 
    202201        c = Context({ 
    203202            'latest_poll_list': latest_poll_list, 
     
    225224Within that, create a file called ``index.html``. Django requires that 
    226225templates have ".html" extension. Note that our 
    227 ``template_loader.get_template('polls/index')`` code from above maps to 
     226``loader.get_template('polls/index')`` code from above maps to 
    228227"[template_directory]/polls/index.html" on the filesystem. 
    229228 
     
    257256        return render_to_response('polls/index', {'latest_poll_list': latest_poll_list}) 
    258257 
    259 Note that we no longer need to import ``template_loader``, ``Context`` or 
     258Note that we no longer need to import ``loader``, ``Context`` or 
    260259``HttpResponse``. 
    261260 
  • django/branches/i18n/docs/tutorial04.txt

    r678 r869  
    198198``<app_label>/<module_name>_detail``. In our case, it'll use the template 
    199199``"polls/polls_detail"``. Thus, rename your ``polls/detail.html`` template to 
    200 ``polls/polls_detail.html``, and change the ``template_loader.get_template()`` 
    201 line in ``vote()``. 
     200``polls/polls_detail.html``, and change the ``render_to_response()`` line in 
     201``vote()``. 
    202202 
    203203Similarly, the ``object_list`` generic view uses a template called 
  • django/branches/i18n/tests/othertests/templates.py

    r836 r869  
    1 from django.core import template, template_loader 
     1from django.core import template 
     2from django.core.template import loader 
    23from django.utils.translation import activate, deactivate 
    34 
     
    260261} 
    261262 
    262 # This replaces the standard template_loader. 
     263# This replaces the standard template loader. 
    263264def test_template_loader(template_name, template_dirs=None): 
    264265    try: 
     
    268269 
    269270def run_tests(verbosity=0, standalone=False): 
    270     template_loader.load_template_source, old_template_loader = test_template_loader, template_loader.load_template_source 
     271    loader.load_template_source, old_template_loader = test_template_loader, loader.load_template_source 
    271272    failed_tests = [] 
    272273    tests = TEMPLATE_TESTS.items() 
     
    276277            activate('*', vals[1]['LANGUAGE_CODE']) 
    277278        try: 
    278             output = template_loader.get_template(name).render(template.Context(vals[1])) 
     279            output = loader.get_template(name).render(template.Context(vals[1])) 
    279280        except Exception, e: 
    280281            if e.__class__ == vals[2]: 
     
    295296                print "Template test: %s -- FAILED. Expected %r, got %r" % (name, vals[2], output) 
    296297            failed_tests.append(name) 
    297     template_loader.load_template_source = old_template_loader 
     298    loader.load_template_source = old_template_loader 
    298299 
    299300    if failed_tests and not standalone: