Skip to content
This repository has been archived by the owner on Dec 17, 2020. It is now read-only.

Commit

Permalink
Port to Python 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
alga committed Feb 27, 2013
1 parent f81aac4 commit c4ef4b1
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 29 deletions.
36 changes: 18 additions & 18 deletions src/z3c/contents/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Now we can create a ContentsPage:
>>> from z3c.contents import browser
>>> firstPage = browser.ContentsPage(container, request)
>>> firstPage.update()
>>> print firstPage.render()
>>> print(firstPage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down Expand Up @@ -191,7 +191,7 @@ for this:
Now let's update and render the contents page again:

>>> firstPage.update()
>>> print firstPage.render()
>>> print(firstPage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down Expand Up @@ -295,7 +295,7 @@ number names and not on the number itself.
>>> alsoProvides(sorterRequest, IDivFormLayer)
>>> sortingPage = browser.ContentsPage(container, sorterRequest)
>>> sortingPage.update()
>>> print sortingPage.render()
>>> print(sortingPage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down Expand Up @@ -393,7 +393,7 @@ Let's make coverage happy and sort on the rename column:
>>> alsoProvides(sorterRequest, IDivFormLayer)
>>> sortingPage = browser.ContentsPage(container, sorterRequest)
>>> sortingPage.update()
>>> print sortingPage.render()
>>> print(sortingPage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down Expand Up @@ -448,7 +448,7 @@ As you can see the second page for the second container has no items and
no buttons:

>>> secondPage.update()
>>> print secondPage.render()
>>> print(secondPage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down Expand Up @@ -507,7 +507,7 @@ be able to paste objects within the same container they're copied from.
>>> alsoProvides(copyRequest, IDivFormLayer)
>>> copyPage = browser.ContentsPage(container, copyRequest)
>>> copyPage.update()
>>> print copyPage.render()
>>> print(copyPage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down Expand Up @@ -619,7 +619,7 @@ from another container.
>>> alsoProvides(pasteRequest, IDivFormLayer)
>>> pastePage = browser.ContentsPage(secondContainer, pasteRequest)
>>> pastePage.update()
>>> print pastePage.render()
>>> print(pastePage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down Expand Up @@ -706,7 +706,7 @@ container.
>>> alsoProvides(cutRequest, IDivFormLayer)
>>> cutPage = browser.ContentsPage(container, cutRequest)
>>> cutPage.update()
>>> print cutPage.render()
>>> print(cutPage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down Expand Up @@ -758,7 +758,7 @@ And we can paste the selectded items to the second container:
>>> alsoProvides(pasteRequest, IDivFormLayer)
>>> pastePage = browser.ContentsPage(secondContainer, pasteRequest)
>>> pastePage.update()
>>> print pastePage.render()
>>> print(pastePage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down Expand Up @@ -846,7 +846,7 @@ item after paste them to the second container. Also the ``paste button`` is
gone:

>>> firstPage.update()
>>> print firstPage.render()
>>> print(firstPage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down Expand Up @@ -938,7 +938,7 @@ items and click the delete button:
>>> alsoProvides(deleteRequest, IDivFormLayer)
>>> deletePage = browser.ContentsPage(container, deleteRequest)
>>> deletePage.update()
>>> print deletePage.render()
>>> print(deletePage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down Expand Up @@ -972,7 +972,7 @@ do the renaming. Let's setup a table which we select items and click the
>>> alsoProvides(renameRequest, IDivFormLayer)
>>> renamePage = browser.ContentsPage(secondContainer, renameRequest)
>>> renamePage.update()
>>> print renamePage.render()
>>> print(renamePage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down Expand Up @@ -1009,7 +1009,7 @@ Now we rename the ``second`` item to ``fifth``:
>>> alsoProvides(renameRequest, IDivFormLayer)
>>> renamePage = browser.ContentsPage(secondContainer, renameRequest)
>>> renamePage.update()
>>> print renamePage.render()
>>> print(renamePage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down Expand Up @@ -1051,7 +1051,7 @@ error. Let's test this:
>>> alsoProvides(renameRequest, IDivFormLayer)
>>> renamePage = browser.ContentsPage(secondContainer, renameRequest)
>>> renamePage.update()
>>> print renamePage.render()
>>> print(renamePage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down Expand Up @@ -1112,7 +1112,7 @@ container or to any possible string attribute.
>>> alsoProvides(searchRequest, IDivFormLayer)
>>> searchPage = browser.ContentsPage(secondContainer, searchRequest)
>>> searchPage.update()
>>> print searchPage.render()
>>> print(searchPage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down Expand Up @@ -1152,7 +1152,7 @@ sort the table by that column.
>>> alsoProvides(headerRequest, IDivFormLayer)
>>> headerPage = browser.ContentsPage(secondContainer, headerRequest)
>>> headerPage.update()
>>> print headerPage.render()
>>> print(headerPage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand All @@ -1175,7 +1175,7 @@ included in the query so as to maintain the search across views.
>>> alsoProvides(searchRequest, IDivFormLayer)
>>> searchPage = browser.ContentsPage(secondContainer, searchRequest)
>>> searchPage.update()
>>> print searchPage.render()
>>> print(searchPage.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down Expand Up @@ -1208,7 +1208,7 @@ row CSS class markers. The default batch size is set to ``25``:
>>> alsoProvides(request, IDivFormLayer)
>>> contents = browser.Contents(secondContainer, request)
>>> contents.update()
>>> print contents.render()
>>> print(contents.render())
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
id="contents" name="contents">
Expand Down
1 change: 1 addition & 0 deletions src/z3c/contents/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def getItemValue(self, item):
def getItemKey(self, item):
name = self.getItemValue(item)
base64Name = base64.urlsafe_b64encode(name.encode('utf-8'))
base64Name = base64Name.decode('utf-8')
return '%s-%s-rename' % (self.id, base64Name)

def getRenameValue(self, item):
Expand Down
12 changes: 5 additions & 7 deletions src/z3c/contents/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@
#
###############################################################################

@zope.interface.implementer(IContainer)
class SampleContainer(btree.BTreeContainer):
"""Sample container."""

zope.interface.implements(IContainer)


class IContentsTestBrowserLayer(z3c.layer.ready2go.IReady2GoBrowserLayer):
"""test layer."""
Expand All @@ -68,10 +67,10 @@ class IContent(zope.interface.Interface):
number = zope.schema.Int(title=u'Number')


@zope.interface.implementer(IContent)
class Content(object):
"""Sample content which is pickable for copy test."""

zope.interface.implements(IContent)

def __init__(self, title, number):
self.title = title
Expand All @@ -82,11 +81,10 @@ def __repr__(self):
self.number)


@zope.interface.implementer(ISearchableText)
@zope.component.adapter(IContent)
class SearchableTextForContent:

zope.interface.implements(ISearchableText)
zope.component.adapts(IContent)

def __init__(self, content):
self.content = content

Expand All @@ -111,8 +109,8 @@ def printElement(browser, xpath, multiple=False, serialize=True):
print(elem)


@zope.interface.implementer(IAnnotations)
class PrincipalAnnotations(dict):
zope.interface.implements(IAnnotations)
data = {}
def __new__(class_, context=None):
try:
Expand Down
8 changes: 7 additions & 1 deletion src/z3c/contents/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"""
__docformat__ = "reStructuredText"

import re
import unittest
from zope.testing import doctest

Expand All @@ -25,6 +26,8 @@
except ImportError:
HAVE_FTESTS = False

from zope.testing.renormalizing import RENormalizing

from z3c.contents import testing


Expand All @@ -49,10 +52,13 @@ def ftest_suite():


def test_suite():
checker = RENormalizing((
(re.compile("u'(.*?)'"), "'\\1'"),
))
return unittest.TestSuite([
doctest.DocFileSuite('README.txt',
setUp=testing.setUp, tearDown=testing.tearDown,
optionflags=optionflags,
optionflags=optionflags, checker=checker,
),
ftest_suite(),
])
Expand Down
6 changes: 3 additions & 3 deletions src/z3c/contents/value.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ def _search_helper(id, obj, container, id_filters, object_filters, result):
_search_helper(key, value, obj, id_filters, object_filters, result)


@zope.interface.implementer(IObjectFindFilter)
class SearchableTextFindFilter(object):
"""Filter objects on the ISearchableText adapters to the object."""

zope.interface.implements(IObjectFindFilter)


def __init__(self, terms):
self.terms = terms

def matches(self, object):
"""Check if one of the search terms is found in the searchable text
interface.
Expand Down

0 comments on commit c4ef4b1

Please sign in to comment.