Permalink
Browse files

Fixed #626 -- Moved template modules to django.core.template package.…

… django.core.template_loader is deprecated, in favor of django.core.template.loader.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@867 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent b773bf4 commit f71f8546283dbdf698c7578f8f9154045c84f9e7 @adrianholovaty adrianholovaty committed Oct 14, 2005
@@ -2,14 +2,13 @@
# of MVC. In other words, these functions/classes introduce controlled coupling
# for convenience's sake.
-from django.core import template_loader
from django.core.exceptions import Http404, ObjectDoesNotExist
-from django.core.template import Context
+from django.core.template import Context, loader
from django.conf.settings import DEBUG, INTERNAL_IPS
from django.utils.httpwrappers import HttpResponse
def render_to_response(*args, **kwargs):
- return HttpResponse(template_loader.render_to_string(*args, **kwargs))
+ return HttpResponse(loader.render_to_string(*args, **kwargs))
load_and_render = render_to_response # For backwards compatibility.
def get_object_or_404(mod, **kwargs):
View
@@ -1,6 +1,5 @@
-from django.core import template_loader
from django.core.exceptions import ObjectDoesNotExist
-from django.core.template import Context
+from django.core.template import Context, loader
from django.models.core import sites
from django.utils import feedgenerator
from django.conf.settings import LANGUAGE_CODE, SETTINGS_MODULE
@@ -28,7 +27,7 @@ def __init__(self, slug, title_cb, link_cb, description_cb, get_list_func_cb, ge
get_list_kwargs_cb -- Function that takes the param and returns a
dictionary to use in addition to get_list_kwargs (if applicable).
-
+
get_pubdate_cb -- Function that takes the object and returns a datetime
to use as the publication date in the feed.
@@ -49,7 +48,7 @@ def __init__(self, slug, title_cb, link_cb, description_cb, get_list_func_cb, ge
self.enc_url = enc_url
self.enc_length = enc_length
self.enc_mime_type = enc_mime_type
-
+
def get_feed(self, param_slug=None):
"""
Returns a utils.feedgenerator.DefaultRssFeed object, fully populated,
@@ -64,8 +63,8 @@ def get_feed(self, param_slug=None):
param = None
current_site = sites.get_current()
f = self._get_feed_generator_object(param)
- title_template = template_loader.get_template('rss/%s_title' % self.slug)
- description_template = template_loader.get_template('rss/%s_description' % self.slug)
+ title_template = loader.get_template('rss/%s_title' % self.slug)
+ description_template = loader.get_template('rss/%s_description' % self.slug)
kwargs = self.get_list_kwargs.copy()
if param and self.get_list_kwargs_cb:
kwargs.update(self.get_list_kwargs_cb(param))
@@ -102,7 +101,7 @@ def get_feed(self, param_slug=None):
pubdate = self.get_pubdate_cb and self.get_pubdate_cb(obj) or None,
)
return f
-
+
def _get_feed_generator_object(self, param):
current_site = sites.get_current()
link = self.link_cb(param).decode()
File renamed without changes.
@@ -1,6 +1,7 @@
"Default variable filters"
-import template, re
+from django.core.template import register_filter, resolve_variable
+import re
import random as random_module
###################
@@ -196,7 +197,7 @@ def dictsort(value, arg):
Takes a list of dicts, returns that list sorted by the property given in
the argument.
"""
- decorated = [(template.resolve_variable('var.' + arg, {'var' : item}), item) for item in value]
+ decorated = [(resolve_variable('var.' + arg, {'var' : item}), item) for item in value]
decorated.sort()
return [item[1] for item in decorated]
@@ -205,7 +206,7 @@ def dictsortreversed(value, arg):
Takes a list of dicts, returns that list sorted in reverse order by the
property given in the argument.
"""
- decorated = [(template.resolve_variable('var.' + arg, {'var' : item}), item) for item in value]
+ decorated = [(resolve_variable('var.' + arg, {'var' : item}), item) for item in value]
decorated.sort()
decorated.reverse()
return [item[1] for item in decorated]
@@ -414,52 +415,51 @@ def pprint(value, _):
from pprint import pformat
return pformat(value)
-# Syntax: template.register_filter(name of filter, callback, has_argument)
-template.register_filter('add', add, True)
-template.register_filter('addslashes', addslashes, False)
-template.register_filter('capfirst', capfirst, False)
-template.register_filter('center', center, True)
-template.register_filter('cut', cut, True)
-template.register_filter('date', date, True)
-template.register_filter('default', default, True)
-template.register_filter('default_if_none', default_if_none, True)
-template.register_filter('dictsort', dictsort, True)
-template.register_filter('dictsortreversed', dictsortreversed, True)
-template.register_filter('divisibleby', divisibleby, True)
-template.register_filter('escape', escape, False)
-template.register_filter('filesizeformat', filesizeformat, False)
-template.register_filter('first', first, False)
-template.register_filter('fix_ampersands', fix_ampersands, False)
-template.register_filter('floatformat', floatformat, False)
-template.register_filter('get_digit', get_digit, True)
-template.register_filter('join', join, True)
-template.register_filter('length', length, False)
-template.register_filter('length_is', length_is, True)
-template.register_filter('linebreaks', linebreaks, False)
-template.register_filter('linebreaksbr', linebreaksbr, False)
-template.register_filter('linenumbers', linenumbers, False)
-template.register_filter('ljust', ljust, True)
-template.register_filter('lower', lower, False)
-template.register_filter('make_list', make_list, False)
-template.register_filter('phone2numeric', phone2numeric, False)
-template.register_filter('pluralize', pluralize, False)
-template.register_filter('pprint', pprint, False)
-template.register_filter('removetags', removetags, True)
-template.register_filter('random', random, False)
-template.register_filter('rjust', rjust, True)
-template.register_filter('slice', slice_, True)
-template.register_filter('slugify', slugify, False)
-template.register_filter('stringformat', stringformat, True)
-template.register_filter('striptags', striptags, False)
-template.register_filter('time', time, True)
-template.register_filter('timesince', timesince, False)
-template.register_filter('title', title, False)
-template.register_filter('truncatewords', truncatewords, True)
-template.register_filter('unordered_list', unordered_list, False)
-template.register_filter('upper', upper, False)
-template.register_filter('urlencode', urlencode, False)
-template.register_filter('urlize', urlize, False)
-template.register_filter('urlizetrunc', urlizetrunc, True)
-template.register_filter('wordcount', wordcount, False)
-template.register_filter('wordwrap', wordwrap, True)
-template.register_filter('yesno', yesno, True)
+# Syntax: register_filter(name of filter, callback, has_argument)
+register_filter('add', add, True)
+register_filter('addslashes', addslashes, False)
+register_filter('capfirst', capfirst, False)
+register_filter('center', center, True)
+register_filter('cut', cut, True)
+register_filter('date', date, True)
+register_filter('default', default, True)
+register_filter('dictsort', dictsort, True)
+register_filter('dictsortreversed', dictsortreversed, True)
+register_filter('divisibleby', divisibleby, True)
+register_filter('escape', escape, False)
+register_filter('filesizeformat', filesizeformat, False)
+register_filter('first', first, False)
+register_filter('fix_ampersands', fix_ampersands, False)
+register_filter('floatformat', floatformat, False)
+register_filter('get_digit', get_digit, True)
+register_filter('join', join, True)
+register_filter('length', length, False)
+register_filter('length_is', length_is, True)
+register_filter('linebreaks', linebreaks, False)
+register_filter('linebreaksbr', linebreaksbr, False)
+register_filter('linenumbers', linenumbers, False)
+register_filter('ljust', ljust, True)
+register_filter('lower', lower, False)
+register_filter('make_list', make_list, False)
+register_filter('phone2numeric', phone2numeric, False)
+register_filter('pluralize', pluralize, False)
+register_filter('pprint', pprint, False)
+register_filter('removetags', removetags, True)
+register_filter('random', random, False)
+register_filter('rjust', rjust, True)
+register_filter('slice', slice_, True)
+register_filter('slugify', slugify, False)
+register_filter('stringformat', stringformat, True)
+register_filter('striptags', striptags, False)
+register_filter('time', time, True)
+register_filter('timesince', timesince, False)
+register_filter('title', title, False)
+register_filter('truncatewords', truncatewords, True)
+register_filter('unordered_list', unordered_list, False)
+register_filter('upper', upper, False)
+register_filter('urlencode', urlencode, False)
+register_filter('urlize', urlize, False)
+register_filter('urlizetrunc', urlizetrunc, True)
+register_filter('wordcount', wordcount, False)
+register_filter('wordwrap', wordwrap, True)
+register_filter('yesno', yesno, True)
Oops, something went wrong.

0 comments on commit f71f854

Please sign in to comment.