Skip to content

Commit

Permalink
Merge b757fa3 into c687207
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Jan 27, 2019
2 parents c687207 + b757fa3 commit 3c89e8e
Show file tree
Hide file tree
Showing 25 changed files with 564 additions and 425 deletions.
11 changes: 11 additions & 0 deletions .coveragerc
@@ -0,0 +1,11 @@
[run]
source = z3c.table

[report]
precision = 2
exclude_lines =
pragma: no cover
if __name__ == '__main__':
raise NotImplementedError
self.fail
raise AssertionError
1 change: 1 addition & 0 deletions .gitignore
@@ -1,5 +1,6 @@
*.egg-info/
*.py[co]
.coverage
.installed.cfg
.tox/
bin/
Expand Down
29 changes: 21 additions & 8 deletions .travis.yml
@@ -1,13 +1,26 @@
language: python
env:
- TOXENV=py26
- TOXENV=py27
- TOXENV=py33
- TOXENV=py34
- TOXENV=pypy
python:
- 2.7
- 3.5
- 3.6
- pypy
- pypy3
matrix:
include:
- python: 3.7
dist: xenial
- python: 3.6
name: "Flake8"
install: pip install -U flake8
script: flake8 --doctests src setup.py
install:
- travis_retry pip install tox
- pip install -U pip setuptools
- pip install -U coverage coveralls
- pip install -U -e .[test]
script:
- tox
- coverage run -m zope.testrunner --test-path=src
after_success:
- coveralls
notifications:
email: false
cache: pip
10 changes: 7 additions & 3 deletions CHANGES.txt → CHANGES.rst
Expand Up @@ -2,10 +2,14 @@
CHANGES
=======

2.0.2 (unreleased)
------------------
2.1 (unreleased)
----------------

- Added support for Python 3.7 and PyPy3.

- Dropped support for running the tests using `python setup.py test`.

- Nothing changed yet.
- Reformatted the code using black and flake8.


2.0.1 (2017-04-19)
Expand Down
17 changes: 17 additions & 0 deletions README.rst
@@ -0,0 +1,17 @@
.. image:: https://img.shields.io/pypi/v/z3c.table.svg
:target: https://pypi.python.org/pypi/z3c.table/
:alt: Latest release

.. image:: https://img.shields.io/pypi/pyversions/z3c.table.svg
:target: https://pypi.org/project/z3c.table/
:alt: Supported Python versions

.. image:: https://travis-ci.org/zopefoundation/z3c.table.svg?branch=master
:target: https://travis-ci.org/zopefoundation/z3c.table

.. image:: https://coveralls.io/repos/github/zopefoundation/z3c.table/badge.svg
:target: https://coveralls.io/github/zopefoundation/z3c.table


This package provides a modular table rendering implementation for Zope3.

1 change: 0 additions & 1 deletion README.txt

This file was deleted.

File renamed without changes.
119 changes: 61 additions & 58 deletions setup.py
Expand Up @@ -22,74 +22,77 @@ def read(*rnames):


setup(
name='z3c.table',
version='2.0.2.dev0',
name="z3c.table",
version="2.1.dev0",
author="Stephan Richter, Roger Ineichen and the Zope Community",
author_email="zope-dev@zope.org",
description="Modular table rendering implementation for Zope3",
long_description=(
read('README.txt')
+ '\n\n' +
read('src', 'z3c', 'table', 'README.txt')
+ '\n\n' +
read('src', 'z3c', 'table', 'sort.txt')
+ '\n\n' +
read('src', 'z3c', 'table', 'batch.txt')
+ '\n\n' +
read('src', 'z3c', 'table', 'sequence.txt')
+ '\n\n' +
read('src', 'z3c', 'table', 'column.txt')
+ '\n\n' +
read('src', 'z3c', 'table', 'miscellaneous.txt')
+ '\n\n' +
read('CHANGES.txt')),
read("README.rst")
+ "\n\n"
+ read("src", "z3c", "table", "README.rst")
+ "\n\n"
+ read("src", "z3c", "table", "sort.rst")
+ "\n\n"
+ read("src", "z3c", "table", "batch.rst")
+ "\n\n"
+ read("src", "z3c", "table", "sequence.rst")
+ "\n\n"
+ read("src", "z3c", "table", "column.rst")
+ "\n\n"
+ read("src", "z3c", "table", "miscellaneous.rst")
+ "\n\n"
+ read("CHANGES.rst")
),
license="ZPL 2.1",
keywords="zope3 z3c table content provider",
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: Zope Public License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Natural Language :: English',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
'Framework :: Zope :: 3'],
url='http://pypi.python.org/pypi/z3c.table',
packages=find_packages('src'),
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: Zope Public License",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Natural Language :: English",
"Operating System :: OS Independent",
"Topic :: Internet :: WWW/HTTP",
"Framework :: Zope :: 3",
],
url="https://github.com/zopefoundation/z3c.table",
packages=find_packages("src"),
include_package_data=True,
package_dir={'': 'src'},
namespace_packages=['z3c'],
package_dir={"": "src"},
namespace_packages=["z3c"],
extras_require=dict(
test=[
'zope.publisher',
'zope.testing',
'zope.container',
'zope.site',
],
),
"zope.container",
"zope.publisher",
"zope.site",
"zope.testing",
"zope.testrunner",
]
),
install_requires=[
'setuptools',
'future>=0.14.0',
'z3c.batching>=1.1.0',
'zope.component',
'zope.contentprovider',
'zope.dublincore',
'zope.i18nmessageid',
'zope.i18n',
'zope.interface',
'zope.location',
'zope.schema',
'zope.security',
'zope.traversing',
],
test_suite='z3c.table.tests.test_suite',
"setuptools",
"future>=0.14.0",
"z3c.batching>=1.1.0",
"zope.component",
"zope.contentprovider",
"zope.dublincore",
"zope.i18nmessageid",
"zope.i18n",
"zope.interface",
"zope.location",
"zope.schema",
"zope.security",
"zope.traversing",
],
zip_safe=False,
)
8 changes: 1 addition & 7 deletions src/z3c/__init__.py
@@ -1,7 +1 @@
# this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
__import__("pkg_resources").declare_namespace(__name__) # pragma: no cover
File renamed without changes.
52 changes: 24 additions & 28 deletions src/z3c/table/batch.py
Expand Up @@ -11,11 +11,6 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id:$
"""
__docformat__ = "reStructuredText"

try:
# Python 2
from urllib import urlencode
Expand All @@ -30,7 +25,7 @@
from z3c.table import interfaces
from z3c.batching.batch import first_neighbours_last

_ = zope.i18nmessageid.MessageFactory('z3c')
_ = zope.i18nmessageid.MessageFactory("z3c")


@zope.interface.implementer(interfaces.IBatchProvider)
Expand All @@ -44,20 +39,20 @@ class BatchProvider(object):
This batch provider offers a batch presentation for a given table. The
batch provides different configuration options which can be overriden in
custom implementations:
The batch acts like this. If we have more batches than
(prevBatchSize + nextBatchSize + 3) then the advanced batch subset is used.
Otherwise, we will render all batch links.
Otherwise, we will render all batch links.
Note, the additional factor 3 is the placeholder for the first, current and
last item.
Such a batch looks like:
Renders the link for the first batch, spacers, the amount of links for
previous batches, the current batch link, spacers, the amount of links for
Renders the link for the first batch, spacers, the amount of links for
previous batches, the current batch link, spacers, the amount of links for
previous batches and the link for the last batch.
Sample for 1000 items with 100 batches with batchSize of 10 and a
Sample for 1000 items with 100 batches with batchSize of 10 and a
prevBatchSize of 3 and a nextBatchSize of 3:
For the first item:
Expand All @@ -74,9 +69,9 @@ class BatchProvider(object):

prevBatchSize = 3
nextBatchSize = 3
batchSpacer = u'...'
batchSpacer = u"..."

_request_args = ['%(prefix)s-sortOn', '%(prefix)s-sortOrder']
_request_args = ["%(prefix)s-sortOn", "%(prefix)s-sortOrder"]

def __init__(self, context, request, table):
self.__parent__ = context
Expand All @@ -101,13 +96,13 @@ def getQueryStringArgs(self):

def renderBatchLink(self, batch, cssClass=None):
args = self.getQueryStringArgs()
args[self.table.prefix +'-batchStart'] = batch.start
args[self.table.prefix +'-batchSize'] = batch.size
args[self.table.prefix + "-batchStart"] = batch.start
args[self.table.prefix + "-batchSize"] = batch.size
query = urlencode(sorted(args.items()))
tableURL = absoluteURL(self.table, self.request)
idx = batch.index + 1
css = ' class="%s"' % cssClass
cssClass = cssClass and css or u''
cssClass = cssClass and css or u""
return '<a href="%s?%s"%s>%s</a>' % (tableURL, query, cssClass, idx)

def update(self):
Expand All @@ -118,11 +113,12 @@ def update(self):
self.batchItems = self.batch.batches
else:
# switch to an advanced batch subset
self.batchItems = first_neighbours_last(self.batches,
self.batch.index,
self.prevBatchSize,
self.nextBatchSize,
)
self.batchItems = first_neighbours_last(
self.batches,
self.batch.index,
self.prevBatchSize,
self.nextBatchSize,
)

def render(self):
self.update()
Expand All @@ -135,14 +131,14 @@ def render(self):
# build css class
cssClasses = []
if batch and batch == self.batch:
cssClasses.append('current')
cssClasses.append("current")
if idx == 1:
cssClasses.append('first')
cssClasses.append("first")
if idx == lastIdx:
cssClasses.append('last')
cssClasses.append("last")

if cssClasses:
css = ' '.join(cssClasses)
css = " ".join(cssClasses)
else:
css = None

Expand All @@ -160,4 +156,4 @@ def render(self):
append(self.renderBatchLink(batch, css))
else:
append(self.renderBatchLink(batch))
return u'\n'.join(res)
return u"\n".join(res)
File renamed without changes.

0 comments on commit 3c89e8e

Please sign in to comment.