Skip to content

Commit

Permalink
Partially revert bce6ce4.
Browse files Browse the repository at this point in the history
We want to restore the old behaviour of repr.
  • Loading branch information
sallner committed Oct 23, 2018
1 parent 0d6f6a4 commit 36f8113
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 40 deletions.
20 changes: 8 additions & 12 deletions src/Products/Five/browser/tests/pages.txt
Expand Up @@ -261,17 +261,13 @@ The parent of the view is the view's context:

The direct parent of the context is

>>> aq_inner(context).__parent__.__class__
<class 'OFS.Folder.Folder'>
>>> print(aq_inner(context).__parent__.getId())
test_folder_1_
>>> aq_inner(context).__parent__
<Folder at /test_folder_1_>

C methods work the same

>>> aq_parent(aq_inner(context)).__class__
<class 'OFS.Folder.Folder'>
>>> print(aq_parent(aq_inner(context)).getId())
test_folder_1_
>>> aq_parent(aq_inner(context))
<Folder at /test_folder_1_>

The same applies to a view registered with <browser:view /> instead of
<browser:page />
Expand All @@ -290,10 +286,10 @@ The same applies to a view registered with <browser:view /> instead of
True
>>> aq_parent(view) == view.context
True
>>> print(aq_inner(context).__parent__.getId())
test_folder_1_
>>> print(aq_parent(aq_inner(context)).getId())
test_folder_1_
>>> aq_inner(context).__parent__
<Folder at /test_folder_1_>
>>> aq_parent(aq_inner(context))
<Folder at /test_folder_1_>

Make sure that methods which are not included in the allowed interface or
attributes, but which already had security declarations from a base class,
Expand Down
43 changes: 17 additions & 26 deletions src/Zope2/App/tests/test_safe_formatter.py
Expand Up @@ -197,10 +197,8 @@ def test_cook_zope3_page_templates_normal(self):
namespace = {'context': self.app}
self.assertEqual(
pt.pt_render(namespace).strip(),
u'<p>{}</p>\n'
u'<p>{}</p>'.format(
escape(repr(self.app).lower()),
escape(repr(self.app).upper())))
u'<p>&lt;application at &gt;</p>\n'
u'<p>&lt;APPLICATION AT &gt;</p>')

def test_cook_zope3_page_templates_using_format(self):
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
Expand All @@ -214,31 +212,27 @@ def test_cook_zope3_page_templates_using_format(self):
self.app.test_folder_1_.__roles__ = ['Manager']
self.assertEqual(
pt.pt_render(namespace).strip(),
u"<p>class of {app_lower} is "
u"<p>class of &lt;application at &gt; is "
u"&lt;class 'ofs.application.application'&gt;</p>\n"
u"<p>CLASS OF {app_upper} IS "
u"<p>CLASS OF &lt;APPLICATION AT &gt; IS "
u"&lt;CLASS 'OFS.APPLICATION.APPLICATION'&gt;</p>\n"
u"<p>{{'foo': {folder}}} has "
u"foo={folder}</p>\n"
u"<p>{{'foo': {folder}}} has "
u"foo={folder}</p>\n"
u"<p>[{folder}] has "
u"first item {folder}</p>\n"
u"<p>[{folder}] has "
u"first item {folder}</p>".format(
app_lower=escape(repr(self.app).lower()),
app_upper=escape(repr(self.app).upper()),
folder=escape(repr(self.app.test_folder_1_))
))
u"<p>{'foo': &lt;Folder at /test_folder_1_&gt;} has "
u"foo=&lt;Folder at test_folder_1_&gt;</p>\n"
u"<p>{'foo': &lt;Folder at /test_folder_1_&gt;} has "
u"foo=&lt;Folder at test_folder_1_&gt;</p>\n"
u"<p>[&lt;Folder at /test_folder_1_&gt;] has "
u"first item &lt;Folder at test_folder_1_&gt;</p>\n"
u"<p>[&lt;Folder at /test_folder_1_&gt;] has "
u"first item &lt;Folder at test_folder_1_&gt;</p>"
)

def test_cook_zope2_page_templates_bad_key_str(self):
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
pt = ZopePageTemplate('mytemplate', BAD_KEY_STR)
hack_pt(pt, self.app)
self.assertEqual(
pt.pt_render(),
'<p>access by key: {}</p>'.format(
escape(repr(self.app.test_folder_1_))))
'<p>access by key: &lt;Folder at test_folder_1_&gt;</p>')
self.app.test_folder_1_.__roles__ = ['Manager']
with self.assertRaises(Unauthorized) as err:
pt.pt_render()
Expand All @@ -252,8 +246,7 @@ def test_cook_zope2_page_templates_bad_key_unicode(self):
hack_pt(pt, self.app)
self.assertEqual(
pt.pt_render(),
'<p>access by key: {}</p>'.format(
escape(repr(self.app.test_folder_1_))))
'<p>access by key: &lt;Folder at test_folder_1_&gt;</p>')
self.app.test_folder_1_.__roles__ = ['Manager']
with self.assertRaises(Unauthorized) as err:
pt.pt_render()
Expand All @@ -268,8 +261,7 @@ def test_cook_zope2_page_templates_bad_item_str(self):
hack_pt(pt, self.app.testlist)
self.assertEqual(
pt.pt_render(),
'<p>access by item: {}</p>'.format(
escape(repr(self.app.test_folder_1_))))
'<p>access by item: &lt;Folder at test_folder_1_&gt;</p>')
self.app.test_folder_1_.__roles__ = ['Manager']
with self.assertRaises(Unauthorized) as err:
pt.pt_render()
Expand All @@ -284,8 +276,7 @@ def test_cook_zope2_page_templates_bad_item_unicode(self):
hack_pt(pt, self.app.testlist)
self.assertEqual(
pt.pt_render(),
'<p>access by item: {}</p>'.format(
escape(repr(self.app.test_folder_1_))))
'<p>access by item: &lt;Folder at test_folder_1_&gt;</p>')
self.app.test_folder_1_.__roles__ = ['Manager']
with self.assertRaises(Unauthorized) as err:
pt.pt_render()
Expand Down
4 changes: 2 additions & 2 deletions src/Zope2/utilities/tests/test_zconsole.py
Expand Up @@ -58,11 +58,11 @@ def test_debug(self):
from Zope2.utilities.zconsole import debug
sys.stdout = StringIO()
got = debug(self.zopeconf)
expected = '<Application '
expected = '<Application at >'
finally:
sys.argv = self.stored_sys_argv
sys.stdout = self.stored_stdout
self.assertTrue(str(got).startswith(expected))
self.assertEqual(expected, str(got))

def test_runscript(self):
script = os.path.join(self.instancedir, 'test_script.py')
Expand Down

0 comments on commit 36f8113

Please sign in to comment.