Skip to content

Commit

Permalink
Do not use cgi module if replacement module html available
Browse files Browse the repository at this point in the history
. Drop pyramid support < 1.5.
  • Loading branch information
rnixx committed Mar 25, 2019
1 parent 9e43377 commit e70f07d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ Changelog
1.0 (unreleased)
----------------

- Drop pyramid support < 1.5.
[rnix, 2019-03-24]

- Python 3 compatibility.
[rnix, 2019-03-24]

- Do not use ``cgi`` module if replacement module ``html`` available.
[rnix, 2019-03-24]

- Convert doctests to unittests.
[rnix, 2019-03-21]

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def run_tests(self):
'setuptools',
'zope.component',
'zope.exceptions',
'pyramid',
'pyramid>=1.5',
'pyramid_chameleon',
],
extras_require=dict(test=['zope.testrunner']),
Expand Down
22 changes: 8 additions & 14 deletions src/cone/tile/_api.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
try:
from pyramid.chameleon_zpt import ZPTTemplateRenderer
except ImportError:
from pyramid_chameleon.zpt import ZPTTemplateRenderer
try:
from pyramid.config import preserve_view_attrs
except ImportError:
from pyramid.config.views import preserve_view_attrs
from pyramid_chameleon.zpt import ZPTTemplateRenderer
from pyramid.config.views import preserve_view_attrs
from pyramid.httpexceptions import HTTPForbidden
from pyramid.interfaces import IAuthenticationPolicy
from pyramid.interfaces import IAuthorizationPolicy
Expand All @@ -16,10 +10,7 @@
from pyramid.interfaces import IViewClassifier
from pyramid.path import caller_package
from pyramid.renderers import RendererHelper
try:
from pyramid.renderers import template_renderer_factory
except ImportError:
from pyramid_chameleon.renderer import template_renderer_factory
from pyramid_chameleon.renderer import template_renderer_factory
from pyramid.threadlocal import get_current_registry
try: # pragma: no coverage
from urllib import quote
Expand All @@ -31,7 +22,10 @@
from zope.interface import Attribute
from zope.interface import Interface
from zope.interface import implementer
import cgi
try: # pragma: no coverage
import html
except ImportError: # pragma: no coverage
import cgi as html
import os
import sys
import traceback
Expand Down Expand Up @@ -168,7 +162,7 @@ def render_tile(model, request, name, catch_errors=True):
logger.debug(msg)
err_msg = str(e).decode('utf-8') if IS_PY2 else str(e)
return u"Tile with name '{}' not found:<br /><pre>{}</pre>".format(
name, cgi.escape(err_msg))
name, html.escape(err_msg))


class TileRenderer(object):
Expand Down
2 changes: 1 addition & 1 deletion src/cone/tile/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def test_inexistent_tile(self):
self.checkOutput("""
Tile with name 'inexistent' not found:<br /><pre>((&lt;cone.tile.tests.Model
... at ...&gt;, &lt;pyramid.testing.DummyRequest object at ...&gt;),
&lt;InterfaceClass cone.tile._api.ITile&gt;, 'inexistent')</pre>
&lt;InterfaceClass cone.tile._api.ITile&gt;, ...inexistent...)</pre>
""", render_tile(model, request, 'inexistent'))

self.checkOutput("""
Expand Down

0 comments on commit e70f07d

Please sign in to comment.