Skip to content

Commit

Permalink
more py3
Browse files Browse the repository at this point in the history
  • Loading branch information
rbu authored and hannosch committed May 13, 2017
1 parent 80fbf13 commit 416f6ae
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
18 changes: 9 additions & 9 deletions src/Products/Five/viewlet/directives.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Next let's see what happens, if we specify a template for the viewlet manager:
>>> ILeftColumn.providedBy(manager)
True
>>> manager.update()
>>> print manager.render().strip()
>>> print(manager.render().strip())
<div class="column">
</div>

Expand Down Expand Up @@ -162,7 +162,7 @@ weight attribute in the viewlet:
>>> ILeftColumn.providedBy(manager)
True
>>> manager.update()
>>> print manager.render().strip()
>>> print(manager.render().strip())
<div class="column">
</div>

Expand Down Expand Up @@ -222,7 +222,7 @@ If we look into the adapter registry, we will find the viewlet:
The manager now also gives us the output of the one and only viewlet:

>>> manager.update()
>>> print manager.render().strip()
>>> print(manager.render().strip())
<div class="column">
<div class="entry">
<div>sunny</div>
Expand Down Expand Up @@ -455,10 +455,10 @@ We now register some viewlets with different permissions:

If we make the request as a manager, we should see both viewlets:

>>> print http(r"""
>>> print(http(r"""
... GET /test_folder_1_/ftf/@@securitytest_view HTTP/1.1
... Authorization: Basic manager:r00t
... """, handle_errors=False)
... """, handle_errors=False))
HTTP/1.1 200 OK
...
<h1>Weather</h1>
Expand All @@ -470,9 +470,9 @@ If we make the request as a manager, we should see both viewlets:

But when we make an anonymous request, we will only see the public viewlet:

>>> print http(r"""
>>> print(http(r"""
... GET /test_folder_1_/ftf/@@securitytest_view HTTP/1.1
... """, handle_errors=False)
... """, handle_errors=False))
HTTP/1.1 200 OK
...
<h1>Weather</h1>
Expand Down Expand Up @@ -508,9 +508,9 @@ that works:
Now we request the view to ensure that we can see the dynamic template
rendered as expected:

>>> print http(r"""
>>> print(http(r"""
... GET /test_folder_1_/ftf/@@securitytest_view HTTP/1.1
... """, handle_errors=False)
... """, handle_errors=False))
HTTP/1.1 200 OK
...
<h1>Weather</h1>
Expand Down
7 changes: 5 additions & 2 deletions src/Products/Five/viewlet/viewlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""

import os
import six
import zope.viewlet.viewlet
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile

Expand All @@ -26,10 +27,12 @@ class ViewletBase(zope.viewlet.viewlet.ViewletBase):
class SimpleAttributeViewlet(zope.viewlet.viewlet.SimpleAttributeViewlet):
pass


class simple(zope.viewlet.viewlet.simple):
# We need to ensure that the proper __init__ is called.
__init__ = ViewletBase.__init__.__func__
if six.PY2:
__init__ = ViewletBase.__init__.__func__
else:
__init__ = ViewletBase.__init__


def SimpleViewletClass(template, bases=(), attributes=None, name=u''):
Expand Down
9 changes: 7 additions & 2 deletions src/Zope2/App/patches/publishing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ def delete_method_docstring(klass, method_name):
# Objects must have a docstring to be published.
# So this avoids them getting published.
method = getattr(klass, method_name, None)
if (method is not None and hasattr(method, 'im_func') and
hasattr(method.im_func, '__doc__')):
if method is None:
return
# Try to remove __doc__ from both attributes so we don't need to rely
# on what attribute Publisher checks first.
if (hasattr(method, 'im_func') and hasattr(method.im_func, '__doc__')):
del method.im_func.__doc__
if (hasattr(method, '__func__') and hasattr(method.__func__, '__doc__')):
del method.__func__.__doc__


element_methods = [
Expand Down

0 comments on commit 416f6ae

Please sign in to comment.