summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2012-09-09 14:05:11 -0400
committerChris McDonough <chrism@plope.com>2012-09-09 14:05:11 -0400
commit3d42722767f2b5843b61f6627aec5ee8080d0f75 (patch)
tree94cb36e3e17f8136380c3bd81d34a7df55d62d08
parent05938c540918fd2e24db69851a7c1cec7ad6630f (diff)
downloadpyramid-3d42722767f2b5843b61f6627aec5ee8080d0f75.tar.gz
pyramid-3d42722767f2b5843b61f6627aec5ee8080d0f75.tar.bz2
pyramid-3d42722767f2b5843b61f6627aec5ee8080d0f75.zip
- The functions from ``pyramid.chameleon_zpt`` and ``pyramid.chameleon_text``
named ``get_renderer``, ``get_template``, ``render_template``, and ``render_template_to_response`` have been removed. These have issued a deprecation warning upon import since Pyramid 1.0. Use ``pyramid.renderers.get_renderer()``, ``pyramid.renderers.get_renderer().implementation()``, ``pyramid.renderers.render()`` or ``pyramid.renderers.render_to_response`` respectively instead of these functions.
-rw-r--r--CHANGES.txt9
-rw-r--r--pyramid/chameleon_text.py92
-rw-r--r--pyramid/chameleon_zpt.py91
-rw-r--r--pyramid/tests/test_chameleon_text.py75
-rw-r--r--pyramid/tests/test_chameleon_zpt.py77
5 files changed, 9 insertions, 335 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index dd5f66e5b..bbe723476 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -174,6 +174,15 @@ Backwards Incompatibilities
This Pyramid release assumes that ``request.path_info`` will
unconditionally be Unicode.
+- The functions from ``pyramid.chameleon_zpt`` and ``pyramid.chameleon_text``
+ named ``get_renderer``, ``get_template``, ``render_template``, and
+ ``render_template_to_response`` have been removed. These have issued a
+ deprecation warning upon import since Pyramid 1.0. Use
+ ``pyramid.renderers.get_renderer()``,
+ ``pyramid.renderers.get_renderer().implementation()``,
+ ``pyramid.renderers.render()`` or ``pyramid.renderers.render_to_response``
+ respectively instead of these functions.
+
Dependencies
------------
diff --git a/pyramid/chameleon_text.py b/pyramid/chameleon_text.py
index 20f614857..f1afb86b5 100644
--- a/pyramid/chameleon_text.py
+++ b/pyramid/chameleon_text.py
@@ -1,6 +1,5 @@
import sys
-from zope.deprecation import deprecated
from zope.interface import implementer
from pyramid.compat import reraise
@@ -20,7 +19,6 @@ from pyramid.interfaces import ITemplateRenderer
from pyramid.decorator import reify
from pyramid import renderers
-from pyramid.path import caller_package
def renderer_factory(info):
return renderers.template_renderer_factory(info, TextTemplateRenderer)
@@ -52,93 +50,3 @@ class TextTemplateRenderer(object):
result = self.template(**system)
return result
-def get_renderer(path):
- """ Return a callable object which can be used to render a
- :term:`Chameleon` text template using the template implied by the
- ``path`` argument. The ``path`` argument may be a
- package-relative path, an absolute path, or a :term:`asset
- specification`.
-
- .. warning::
-
- This API is deprecated in :app:`Pyramid` 1.0. Use
- :func:`pyramid.renderers.get_renderer` instead.
- """
- package = caller_package()
- factory = renderers.RendererHelper(path, package=package)
- return factory.get_renderer()
-
-deprecated(
- 'get_renderer',
- '(pyramid.chameleon_text.get_renderer is deprecated '
- 'as of Pyramid 1.0; instead use pyramid.renderers.get_renderer)')
-
-def get_template(path):
- """ Return the underyling object representing a :term:`Chameleon`
- text template using the template implied by the ``path`` argument.
- The ``path`` argument may be a package-relative path, an absolute
- path, or a :term:`asset specification`.
-
- .. warning::
-
- This API is deprecated in :app:`Pyramid` 1.0. Use
- the ``implementation()`` method of a template renderer retrieved via
- :func:`pyramid.renderers.get_renderer` instead.
- """
- package = caller_package()
- factory = renderers.RendererHelper(path, package=package)
- return factory.get_renderer().implementation()
-
-deprecated(
- 'get_template',
- '(pyramid.chameleon_text.get_template is deprecated '
- 'as of Pyramid 1.0; instead use '
- 'pyramid.renderers.get_renderer().implementation())')
-
-def render_template(path, **kw):
- """ Render a :term:`Chameleon` text template using the template
- implied by the ``path`` argument. The ``path`` argument may be a
- package-relative path, an absolute path, or a :term:`asset
- specification`. The arguments in ``*kw`` are passed as top-level
- names to the template, and so may be used within the template
- itself. Returns a string.
-
- .. warning::
-
- This API is deprecated in :app:`Pyramid` 1.0. Use
- :func:`pyramid.renderers.render` instead.
- """
- package = caller_package()
- request = kw.pop('request', None)
- renderer = renderers.RendererHelper(path, package=package)
- return renderer.render(kw, None, request=request)
-
-deprecated(
- 'render_template',
- '(pyramid.chameleon_text.render_template is deprecated '
- 'as of Pyramid 1.0; instead use pyramid.renderers.render)')
-
-def render_template_to_response(path, **kw):
- """ Render a :term:`Chameleon` text template using the template
- implied by the ``path`` argument. The ``path`` argument may be a
- package-relative path, an absolute path, or a :term:`asset
- specification`. The arguments in ``*kw`` are passed as top-level
- names to the template, and so may be used within the template
- itself. Returns a :term:`Response` object with the body as the
- template result.
-
- .. warning::
-
- This API is deprecated in :app:`Pyramid` 1.0. Use
- :func:`pyramid.renderers.render_to_response` instead.
- """
- package = caller_package()
- request = kw.pop('request', None)
- renderer = renderers.RendererHelper(path, package=package)
- return renderer.render_to_response(kw, None, request=request)
-
-deprecated(
- 'render_template_to_response',
- '(pyramid.chameleon_text.render_template_to_response is deprecated '
- 'as of Pyramid 1.0; instead use pyramid.renderers.render_to_response)')
-
diff --git a/pyramid/chameleon_zpt.py b/pyramid/chameleon_zpt.py
index 9f9e09850..d9f4337fa 100644
--- a/pyramid/chameleon_zpt.py
+++ b/pyramid/chameleon_zpt.py
@@ -1,6 +1,5 @@
import sys
-from zope.deprecation import deprecated
from zope.interface import implementer
from pyramid.compat import reraise
@@ -18,7 +17,6 @@ except ImportError: # pragma: no cover
from pyramid.interfaces import ITemplateRenderer
from pyramid.decorator import reify
-from pyramid.path import caller_package
from pyramid import renderers
def renderer_factory(info):
@@ -58,92 +56,3 @@ class ZPTTemplateRenderer(object):
result = self.template(**system)
return result
-def get_renderer(path):
- """ Return a callable object which can be used to render a
- :term:`Chameleon` ZPT template using the template implied by the
- ``path`` argument. The ``path`` argument may be a
- package-relative path, an absolute path, or a :term:`asset
- specification`.
-
- .. warning::
-
- This API is deprecated in :app:`Pyramid` 1.0. Use
- :func:`pyramid.renderers.get_renderer` instead.
- """
- package = caller_package()
- factory = renderers.RendererHelper(name=path, package=package)
- return factory.get_renderer()
-
-deprecated(
- 'get_renderer',
- '(pyramid.chameleon_zpt.get_renderer is deprecated '
- 'as of Pyramid 1.0; instead use pyramid.renderers.get_renderer)')
-
-def get_template(path):
- """ Return the underyling object representing a :term:`Chameleon`
- ZPT template using the template implied by the ``path`` argument.
- The ``path`` argument may be a package-relative path, an absolute
- path, or a :term:`asset specification`.
-
- .. warning::
-
- This API is deprecated in :app:`Pyramid` 1.0. Use
- the ``implementation()`` method of a template renderer retrieved via
- :func:`pyramid.renderers.get_renderer` instead.
- """
- package = caller_package()
- factory = renderers.RendererHelper(name=path, package=package)
- return factory.get_renderer().implementation()
-
-deprecated(
- 'get_template',
- '(pyramid.chameleon_zpt.get_template is deprecated '
- 'as of Pyramid 1.0; instead use '
- 'pyramid.renderers.get_renderer().implementation())')
-
-def render_template(path, **kw):
- """ Render a :term:`Chameleon` ZPT template using the template
- implied by the ``path`` argument. The ``path`` argument may be a
- package-relative path, an absolute path, or a :term:`asset
- specification`. The arguments in ``*kw`` are passed as top-level
- names to the template, and so may be used within the template
- itself. Returns a string.
-
- .. warning::
-
- This API is deprecated in :app:`Pyramid` 1.0. Use
- :func:`pyramid.renderers.render` instead.
- """
- package = caller_package()
- request = kw.pop('request', None)
- renderer = renderers.RendererHelper(name=path, package=package)
- return renderer.render(kw, None, request=request)
-
-deprecated(
- 'render_template',
- '(pyramid.chameleon_zpt.render_template is deprecated as of Pyramid 1.0; '
- 'instead use pyramid.renderers.render)')
-
-def render_template_to_response(path, **kw):
- """ Render a :term:`Chameleon` ZPT template using the template
- implied by the ``path`` argument. The ``path`` argument may be a
- package-relative path, an absolute path, or a :term:`asset
- specification`. The arguments in ``*kw`` are passed as top-level
- names to the template, and so may be used within the template
- itself. Returns a :term:`Response` object with the body as the
- template result.
-
- .. warning::
-
- This API is deprecated in :app:`Pyramid` 1.0. Use
- :func:`pyramid.renderers.render_to_response` instead.
- """
- package = caller_package()
- request = kw.pop('request', None)
- renderer = renderers.RendererHelper(name=path, package=package)
- return renderer.render_to_response(kw, None, request=request)
-
-deprecated(
- 'render_template_to_response',
- '(pyramid.chameleon_zpt.render_template_to_response is deprecated; as of '
- 'Pyramid 1.0, instead use pyramid.renderers.render_to_response)')
diff --git a/pyramid/tests/test_chameleon_text.py b/pyramid/tests/test_chameleon_text.py
index 8d23c8753..019d63ec0 100644
--- a/pyramid/tests/test_chameleon_text.py
+++ b/pyramid/tests/test_chameleon_text.py
@@ -127,81 +127,6 @@ class TextTemplateRendererTests(Base, unittest.TestCase):
self.assertTrue(isinstance(result, binary_type))
self.assertEqual(result, b'Hello.\n')
-class RenderTemplateTests(Base, unittest.TestCase):
- def _callFUT(self, name, **kw):
- from pyramid.chameleon_text import render_template
- return render_template(name, **kw)
-
- @skip_on('java')
- def test_it(self):
- minimal = self._getTemplatePath('minimal.txt')
- result = self._callFUT(minimal)
- self.assertTrue(isinstance(result, binary_type))
- self.assertEqual(result, b'Hello.\n')
-
-class RenderTemplateToResponseTests(Base, unittest.TestCase):
- def _callFUT(self, name, **kw):
- from pyramid.chameleon_text import render_template_to_response
- return render_template_to_response(name, **kw)
-
- @skip_on('java')
- def test_minimal(self):
- minimal = self._getTemplatePath('minimal.txt')
- result = self._callFUT(minimal)
- from webob import Response
- self.assertTrue(isinstance(result, Response))
- self.assertEqual(result.app_iter, [b'Hello.\n'])
- self.assertEqual(result.status, '200 OK')
- self.assertEqual(len(result.headerlist), 2)
-
- @skip_on('java')
- def test_iresponsefactory_override(self):
- from webob import Response
- class Response2(Response):
- pass
- from pyramid.interfaces import IResponseFactory
- self._registerUtility(Response2, IResponseFactory)
- minimal = self._getTemplatePath('minimal.txt')
- result = self._callFUT(minimal)
- self.assertTrue(isinstance(result, Response2))
-
-class GetRendererTests(Base, unittest.TestCase):
- def _callFUT(self, name):
- from pyramid.chameleon_text import get_renderer
- return get_renderer(name)
-
- @skip_on('java')
- def test_it(self):
- from pyramid.interfaces import IRendererFactory
- class Dummy:
- template = object()
- def implementation(self): pass
- renderer = Dummy()
- def rf(spec):
- return renderer
- self._registerUtility(rf, IRendererFactory, name='foo')
- result = self._callFUT('foo')
- self.assertTrue(result is renderer)
-
-class GetTemplateTests(Base, unittest.TestCase):
- def _callFUT(self, name):
- from pyramid.chameleon_text import get_template
- return get_template(name)
-
- @skip_on('java')
- def test_it(self):
- from pyramid.interfaces import IRendererFactory
- class Dummy:
- template = object()
- def implementation(self):
- return self.template
- renderer = Dummy()
- def rf(spec):
- return renderer
- self._registerUtility(rf, IRendererFactory, name='foo')
- result = self._callFUT('foo')
- self.assertTrue(result is renderer.template)
-
class DummyLookup(object):
auto_reload=True
debug = True
diff --git a/pyramid/tests/test_chameleon_zpt.py b/pyramid/tests/test_chameleon_zpt.py
index e7a1499e6..b85b84159 100644
--- a/pyramid/tests/test_chameleon_zpt.py
+++ b/pyramid/tests/test_chameleon_zpt.py
@@ -132,83 +132,6 @@ class ZPTTemplateRendererTests(Base, unittest.TestCase):
'<div xmlns="http://www.w3.org/1999/xhtml">\n</div>')
-class RenderTemplateTests(Base, unittest.TestCase):
- def _callFUT(self, name, **kw):
- from pyramid.chameleon_zpt import render_template
- return render_template(name, **kw)
-
- @skip_on('java')
- def test_it(self):
- minimal = self._getTemplatePath('minimal.pt')
- result = self._callFUT(minimal)
- self.assertTrue(isinstance(result, text_type))
- self.assertEqual(result.rstrip('\n'),
- '<div xmlns="http://www.w3.org/1999/xhtml">\n</div>')
-
-class RenderTemplateToResponseTests(Base, unittest.TestCase):
- def _callFUT(self, name, **kw):
- from pyramid.chameleon_zpt import render_template_to_response
- return render_template_to_response(name, **kw)
-
- @skip_on('java')
- def test_it(self):
- minimal = self._getTemplatePath('minimal.pt')
- result = self._callFUT(minimal)
- from webob import Response
- self.assertTrue(isinstance(result, Response))
- self.assertEqual(result.app_iter[0].rstrip(b'\n'),
- b'<div xmlns="http://www.w3.org/1999/xhtml">\n</div>')
- self.assertEqual(result.status, '200 OK')
- self.assertEqual(len(result.headerlist), 2)
-
- @skip_on('java')
- def test_iresponsefactory_override(self):
- from webob import Response
- class Response2(Response):
- pass
- from pyramid.interfaces import IResponseFactory
- self._registerUtility(Response2, IResponseFactory)
- minimal = self._getTemplatePath('minimal.pt')
- result = self._callFUT(minimal)
- self.assertTrue(isinstance(result, Response2))
-
-class GetRendererTests(Base, unittest.TestCase):
- def _callFUT(self, name):
- from pyramid.chameleon_zpt import get_renderer
- return get_renderer(name)
-
- @skip_on('java')
- def test_it(self):
- from pyramid.interfaces import IRendererFactory
- class Dummy:
- template = object()
- def implementation(self): pass
- renderer = Dummy()
- def rf(spec):
- return renderer
- self._registerUtility(rf, IRendererFactory, name='foo')
- result = self._callFUT('foo')
- self.assertTrue(result is renderer)
-
-class GetTemplateTests(Base, unittest.TestCase):
- def _callFUT(self, name):
- from pyramid.chameleon_zpt import get_template
- return get_template(name)
-
- @skip_on('java')
- def test_it(self):
- from pyramid.interfaces import IRendererFactory
- class Dummy:
- template = object()
- def implementation(self):
- return self.template
- renderer = Dummy()
- def rf(spec):
- return renderer
- self._registerUtility(rf, IRendererFactory, name='foo')
- result = self._callFUT('foo')
- self.assertTrue(result is renderer.template)
-
class DummyLookup(object):
auto_reload=True
debug = True