pyams-table 1.0.0__py3.5.egg

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. EGG-INFO/PKG-INFO +55 -0
  2. EGG-INFO/SOURCES.txt +32 -0
  3. EGG-INFO/dependency_links.txt +1 -0
  4. EGG-INFO/namespace_packages.txt +1 -0
  5. EGG-INFO/not-zip-safe +1 -0
  6. EGG-INFO/requires.txt +14 -0
  7. EGG-INFO/top_level.txt +1 -0
  8. pyams_table/__init__.py +29 -0
  9. pyams_table/__pycache__/__init__.cpython-35.pyc +0 -0
  10. pyams_table/__pycache__/batch.cpython-35.pyc +0 -0
  11. pyams_table/__pycache__/column.cpython-35.pyc +0 -0
  12. pyams_table/__pycache__/header.cpython-35.pyc +0 -0
  13. pyams_table/__pycache__/include.cpython-35.pyc +0 -0
  14. pyams_table/__pycache__/interfaces.cpython-35.pyc +0 -0
  15. pyams_table/__pycache__/table.cpython-35.pyc +0 -0
  16. pyams_table/__pycache__/testing.cpython-35.pyc +0 -0
  17. pyams_table/__pycache__/value.cpython-35.pyc +0 -0
  18. pyams_table/batch.py +159 -0
  19. pyams_table/column.py +495 -0
  20. pyams_table/doctests/README.rst +668 -0
  21. pyams_table/doctests/batch.rst +660 -0
  22. pyams_table/doctests/column.rst +1274 -0
  23. pyams_table/doctests/miscellaneous.rst +123 -0
  24. pyams_table/doctests/sequence.rst +267 -0
  25. pyams_table/doctests/sort.rst +388 -0
  26. pyams_table/header.py +102 -0
  27. pyams_table/include.py +27 -0
  28. pyams_table/interfaces.py +249 -0
  29. pyams_table/locales/fr/LC_MESSAGES/pyams_table.mo +0 -0
  30. pyams_table/locales/fr/LC_MESSAGES/pyams_table.po +40 -0
  31. pyams_table/locales/pyams_table.pot +41 -0
  32. pyams_table/table.py +383 -0
  33. pyams_table/testing.py +129 -0
  34. pyams_table/tests/__init__.py +29 -0
  35. pyams_table/tests/__pycache__/__init__.cpython-35.pyc +0 -0
  36. pyams_table/tests/__pycache__/test_utilsdocs.cpython-35.pyc +0 -0
  37. pyams_table/tests/__pycache__/test_utilsdocstrings.cpython-35.pyc +0 -0
  38. pyams_table/tests/test_utilsdocs.py +60 -0
  39. pyams_table/tests/test_utilsdocstrings.py +65 -0
  40. pyams_table/value.py +51 -0
EGG-INFO/PKG-INFO ADDED
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyams-table
3
+ Version: 1.0.0
4
+ Summary: PyAMS management package for HTML tables
5
+ Home-page: https://pyams.readthedocs.io
6
+ Author: Thierry Florac
7
+ Author-email: tflorac@ulthar.net
8
+ License: ZPL
9
+ Description: ===================
10
+ PyAMS_table package
11
+ ===================
12
+
13
+ .. contents::
14
+
15
+
16
+ What is PyAMS?
17
+ ==============
18
+
19
+ PyAMS (Pyramid Application Management Suite) is a small suite of packages written for applications
20
+ and content management with the Pyramid framework.
21
+
22
+ **PyAMS** is actually mainly used to manage web sites through content management applications (CMS,
23
+ see PyAMS_content package), but many features are generic and can be used inside any kind of web
24
+ application.
25
+
26
+ All PyAMS documentation is available on `ReadTheDocs <https://pyams.readthedocs.io>`_; source code
27
+ is available on `Gitlab <https://gitlab.com/pyams>`_.
28
+
29
+
30
+ What is PyAMS_table?
31
+ ====================
32
+
33
+ PyAMS_table is a fork of `z3c.table <https://github.com/zopefoundation/z3c.table>`_ package;
34
+ it provides the same features to generate HTML tables, but adapted to the Pyramid framework.
35
+
36
+ ** Package API is also converted to common Python standards, using snake_case for variables and
37
+ methods.
38
+
39
+
40
+ Changelog
41
+ =========
42
+
43
+ 1.0.0
44
+ -----
45
+ - initial release
46
+
47
+ Keywords: Pyramid PyAMS
48
+ Platform: UNKNOWN
49
+ Classifier: License :: OSI Approved :: Zope Public License
50
+ Classifier: Development Status :: 4 - Beta
51
+ Classifier: Programming Language :: Python
52
+ Classifier: Framework :: Pyramid
53
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
54
+ Requires-Python: >=3.5
55
+ Provides-Extra: test
EGG-INFO/SOURCES.txt ADDED
@@ -0,0 +1,32 @@
1
+ MANIFEST.in
2
+ setup.py
3
+ docs/HISTORY.txt
4
+ docs/README.txt
5
+ src/pyams_table/__init__.py
6
+ src/pyams_table/batch.py
7
+ src/pyams_table/column.py
8
+ src/pyams_table/header.py
9
+ src/pyams_table/include.py
10
+ src/pyams_table/interfaces.py
11
+ src/pyams_table/table.py
12
+ src/pyams_table/testing.py
13
+ src/pyams_table/value.py
14
+ src/pyams_table.egg-info/PKG-INFO
15
+ src/pyams_table.egg-info/SOURCES.txt
16
+ src/pyams_table.egg-info/dependency_links.txt
17
+ src/pyams_table.egg-info/namespace_packages.txt
18
+ src/pyams_table.egg-info/not-zip-safe
19
+ src/pyams_table.egg-info/requires.txt
20
+ src/pyams_table.egg-info/top_level.txt
21
+ src/pyams_table/doctests/README.rst
22
+ src/pyams_table/doctests/batch.rst
23
+ src/pyams_table/doctests/column.rst
24
+ src/pyams_table/doctests/miscellaneous.rst
25
+ src/pyams_table/doctests/sequence.rst
26
+ src/pyams_table/doctests/sort.rst
27
+ src/pyams_table/locales/pyams_table.pot
28
+ src/pyams_table/locales/fr/LC_MESSAGES/pyams_table.mo
29
+ src/pyams_table/locales/fr/LC_MESSAGES/pyams_table.po
30
+ src/pyams_table/tests/__init__.py
31
+ src/pyams_table/tests/test_utilsdocs.py
32
+ src/pyams_table/tests/test_utilsdocstrings.py
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+
EGG-INFO/not-zip-safe ADDED
@@ -0,0 +1 @@
1
+
EGG-INFO/requires.txt ADDED
@@ -0,0 +1,14 @@
1
+ setuptools
2
+ pyams_batching
3
+ pyams_utils
4
+ pyramid
5
+ zope.component
6
+ zope.container
7
+ zope.contentprovider
8
+ zope.dublincore
9
+ zope.interface
10
+ zope.location
11
+ zope.schema
12
+ zope.security
13
+
14
+ [test]
EGG-INFO/top_level.txt ADDED
@@ -0,0 +1 @@
1
+ pyams_table
@@ -0,0 +1,29 @@
1
+ #
2
+ # Copyright (c) 2015-2019 Thierry Florac <tflorac AT ulthar.net>
3
+ # All Rights Reserved.
4
+ #
5
+ # This software is subject to the provisions of the Zope Public License,
6
+ # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
7
+ # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
8
+ # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9
+ # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
10
+ # FOR A PARTICULAR PURPOSE.
11
+ #
12
+
13
+ """PyAMS_table package
14
+
15
+ PyAMS management package for HTML tables
16
+ """
17
+
18
+ __docformat__ = 'restructuredtext'
19
+
20
+ from pyramid.i18n import TranslationStringFactory
21
+
22
+
23
+ _ = TranslationStringFactory('pyams_table')
24
+
25
+
26
+ def includeme(config):
27
+ """pyams_table features include"""
28
+ from .include import include_package # pylint: disable=import-outside-toplevel
29
+ include_package(config)
pyams_table/batch.py ADDED
@@ -0,0 +1,159 @@
1
+ #
2
+ # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
3
+ # All Rights Reserved.
4
+ #
5
+ # This software is subject to the provisions of the Zope Public License,
6
+ # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
7
+ # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
8
+ # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9
+ # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
10
+ # FOR A PARTICULAR PURPOSE.
11
+ #
12
+
13
+ """PyAMS_table.batch module
14
+
15
+ This module provides batch features for tables, using PyAMS_batching package.
16
+ """
17
+
18
+ from pyramid.encode import urlencode
19
+ from pyramid.interfaces import IRequest
20
+ from zope.interface import Interface
21
+
22
+ from pyams_batching.batch import first_neighbours_last
23
+ from pyams_table.interfaces import IBatchProvider, ITable
24
+ from pyams_utils.adapter import adapter_config
25
+ from pyams_utils.url import absolute_url
26
+
27
+
28
+ @adapter_config(name='batch',
29
+ context=(Interface, IRequest, ITable),
30
+ provides=IBatchProvider)
31
+ class BatchProvider:
32
+ """Batch content provider
33
+
34
+ A batch provider is responsible for rendering the batch HTML and not for
35
+ batching. The batch setup is directly done in the table. A batch provider
36
+ get only used if the table rows is a batch.
37
+
38
+ This batch provider offers a batch presentation for a given table. The
39
+ batch provides different configuration options which can be overriden in
40
+ custom implementations:
41
+
42
+ The batch acts like this. If we have more batches than
43
+ (prev_batch_size + next_batch_size + 3) then the advanced batch subset is used.
44
+ Otherwise, we will render all batch links.
45
+ Note, the additional factor 3 is the placeholder for the first, current and
46
+ last item.
47
+
48
+ Such a batch looks like:
49
+
50
+ Renders the link for the first batch, spacers, the amount of links for
51
+ previous batches, the current batch link, spacers, the amount of links for
52
+ previous batches and the link for the last batch.
53
+
54
+ Sample for 1000 items with 100 batches with batchSize of 10 and a
55
+ prev_batch_size of 3 and a next_batch_size of 3:
56
+
57
+ For the first item:
58
+ [*1*][2][3][4] ... [100]
59
+
60
+ In the middle:
61
+ [1] ... [6][7][8][*9*][10][11][12] ... [100]
62
+
63
+ At the end:
64
+ [1] ... [97][98][99][*100*]
65
+ """
66
+
67
+ batch_items = []
68
+
69
+ prev_batch_size = 3
70
+ next_batch_size = 3
71
+ batch_spacer = u"..."
72
+
73
+ _request_args = ["%(prefix)s-sort-on", "%(prefix)s-sort-order"]
74
+
75
+ def __init__(self, context, request, table):
76
+ self.__parent__ = context
77
+ self.context = context
78
+ self.request = request
79
+ self.table = table
80
+ self.batch = table.rows
81
+ self.batches = table.rows.batches
82
+
83
+ def get_query_string_args(self):
84
+ """Collect additional terms from the request to include in links.
85
+
86
+ API borrowed from pyams_table.header.ColumnHeader.
87
+ """
88
+ args = {}
89
+ for key in self._request_args:
90
+ key = key % dict(prefix=self.table.prefix)
91
+ value = self.request.params.get(key, None)
92
+ if value:
93
+ args.update({key: value})
94
+ return args
95
+
96
+ def render_batch_link(self, batch, css_class=None):
97
+ """Render batch link"""
98
+ args = self.get_query_string_args()
99
+ args[self.table.prefix + "-batch-start"] = batch.start
100
+ args[self.table.prefix + "-batch-size"] = batch.size
101
+ query = urlencode(sorted(args.items()))
102
+ table_url = absolute_url(self.table, self.request)
103
+ idx = batch.index + 1
104
+ css = ' class="%s"' % css_class
105
+ css_class = css if css_class else ''
106
+ return '<a href="%s?%s"%s>%s</a>' % (table_url, query, css_class, idx)
107
+
108
+ def update(self):
109
+ """Update batch"""
110
+ # 3 is is the placeholder for the first, current and last item.
111
+ total = self.prev_batch_size + self.next_batch_size + 3
112
+ if self.batch.total <= total:
113
+ # give all batches
114
+ self.batch_items = self.batch.batches
115
+ else:
116
+ # switch to an advanced batch subset
117
+ self.batch_items = first_neighbours_last(self.batches,
118
+ self.batch.index,
119
+ self.prev_batch_size,
120
+ self.next_batch_size)
121
+
122
+ def render(self):
123
+ """Render batch"""
124
+ self.update()
125
+ res = []
126
+ append = res.append
127
+ idx = 0
128
+ last_idx = len(self.batch_items)
129
+ for batch in self.batch_items:
130
+ idx += 1
131
+ # build css class
132
+ css_classes = []
133
+ if batch and batch == self.batch:
134
+ css_classes.append("current")
135
+ if idx == 1:
136
+ css_classes.append("first")
137
+ if idx == last_idx:
138
+ css_classes.append("last")
139
+
140
+ if css_classes:
141
+ css = " ".join(css_classes)
142
+ else:
143
+ css = None
144
+
145
+ # render spaces
146
+ if batch is None:
147
+ append(self.batch_spacer)
148
+ elif idx == 1:
149
+ # render first
150
+ append(self.render_batch_link(batch, css))
151
+ elif batch == self.batch:
152
+ # render current
153
+ append(self.render_batch_link(batch, css))
154
+ elif idx == last_idx:
155
+ # render last
156
+ append(self.render_batch_link(batch, css))
157
+ else:
158
+ append(self.render_batch_link(batch))
159
+ return u"\n".join(res)