Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Fixes to support Python 3 #2

Merged
merged 4 commits into from
Jun 16, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions betahaus/viewcomponent/fixtures/contexts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pyramid.testing import DummyResource

from zope.interface import Interface
from zope.interface import implements
from zope.interface import implementer


class IRoot(Interface):
Expand All @@ -11,8 +11,10 @@ class IOrganisation(Interface):
pass


@implementer(IRoot)
class Root(DummyResource):
implements(IRoot)
pass

@implementer(IOrganisation)
class Organisation(DummyResource):
implements(IOrganisation)
pass
10 changes: 6 additions & 4 deletions betahaus/viewcomponent/models.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from zope.interface import implements
from zope.interface import implementer
from pyramid.security import has_permission
from pyramid.traversal import find_interface

from betahaus.viewcomponent.interfaces import IViewGroup


@implementer(IViewGroup)
class ViewGroup(object):
""" Named utility for views. Behaves like an ordered dict with some extra funkyness.
See interfaces.py for documentation.
"""
implements(IViewGroup)

def __init__(self, name = None, perm_checker = None):
self.name = name
Expand All @@ -28,8 +28,10 @@ def __call__(self, context, request, **kw):
for va in self.get_context_vas(context, request):
try:
output = va(context, request, **kw)
except Exception, exc:
exc.message = "ViewAction '%s' of ViewGroup '%s' raised an exception: %s" % (va.name, self.name, exc.message)
except Exception as exc:
eargs = list(exc.args)
eargs[0] = "ViewAction '%s' of ViewGroup '%s' raised an exception: %s" % (va.name, self.name, exc.args[0])
exc.args = eargs
raise exc
if not isinstance(output, basestring):
raise TypeError("ViewAction '%s' of ViewGroup '%s' didn't return a string. Output was: %s" % (va.name, self.name, output))
Expand Down
5 changes: 3 additions & 2 deletions betahaus/viewcomponent/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_call_exception_from_va(self):
try:
obj(None, None)
except Exception, exc:
self.failUnless('this_view_group' in exc.message)
self.failUnless('this_view_group' in exc.args[0])

def test_default_order(self):
obj = self._cut()
Expand Down Expand Up @@ -272,7 +272,8 @@ def test_render_view_groups(self):
context = testing.DummyResource()
self.config.include("betahaus.viewcomponent.fixtures.dummy")
res = self._fut(context, request, 'html')
expected = "pyramid.testing.DummyResource, <class 'pyramid.testing.DummyRequest'>, <betahaus.viewcomponent.models.ViewAction 'stuff'>"
expected = "{}, {}, <betahaus.viewcomponent.models.ViewAction 'stuff'>".format(
testing.DummyResource, testing.DummyRequest)
self.assertEqual(res, expected)


Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
install_requires=requires,
tests_require=requires,
test_suite="betahaus.viewcomponent",
use_2to3=True,
entry_points = """\
""",
paster_plugins=['pyramid'],
Expand Down