Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plone6 / Py3 support #16

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
76a672c
Fix Py3 TypeError
fngaha Nov 22, 2021
dd49873
Fix Py3 Errors
fngaha Nov 22, 2021
7ab482a
fix startup in plone 6
pbauer Jun 10, 2022
0afac9f
Use bootstrap styling
Gomez Sep 28, 2022
51dfec7
fix broken imports for Plone 6.0.5
pbauer May 31, 2023
2ab6cac
Works with eea.facetednavigation v16 and newer
Gomez Oct 24, 2023
8d614a4
Add and load plone6 compatible resources
Gomez Oct 24, 2023
8956902
Preparing release 2.25
gbastien Oct 27, 2023
81ab4c8
Back to development: 2.26
gbastien Oct 27, 2023
a9060ba
Take into account `VocabularyColumn.ignored_value` in `AbbrColumn`.
gbastien Nov 23, 2023
d234d11
Preparing release 2.26
gbastien Nov 27, 2023
855711c
Back to development: 2.27
gbastien Nov 27, 2023
91fe501
Shorted code
gbastien Dec 11, 2023
d543927
When `the_object=True`, `attrName` may be a callable.
gbastien Apr 19, 2024
e091537
Use backports.functools-lru-cache = 1.6.4, six = 1.16.0
gbastien Apr 22, 2024
d5066d7
Fix Py3 TypeError
fngaha Nov 22, 2021
719ddc5
Fix Py3 Errors
fngaha Nov 22, 2021
4a6581e
fix startup in plone 6
pbauer Jun 10, 2022
bebe97b
Use bootstrap styling
Gomez Sep 28, 2022
d93e955
fix broken imports for Plone 6.0.5
pbauer May 31, 2023
3838ba6
Works with eea.facetednavigation v16 and newer
Gomez Oct 24, 2023
d5bc0f2
Add and load plone6 compatible resources
Gomez Oct 24, 2023
fb9c019
Merge remote-tracking branch 'remotes/origin/plone6' into plone6
Gomez May 8, 2024
78fadfb
Avoid `ImportError` on Plone 6 when datagridfield is absent
laulaz Jun 10, 2024
0413515
remove dependency on imio.helpers
pbauer Oct 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@ Changelog
=========


2.25 (unreleased)
2.27 (unreleased)
-----------------

- When `the_object=True`, `attrName` may be a callable.
[gbastien]

2.26 (2023-11-27)
-----------------

- Take into account `VocabularyColumn.ignored_value` in `AbbrColumn`.
[gbastien]

2.25 (2023-10-27)
-----------------

- In `DateColumn.renderCell`, no need to manage a `DateTime` as it is supported
by `api.portal.get_localized_time`.
[gbastien]
- Fix Py3 Errors
[fngaha]

2.24 (2023-10-19)
-----------------
Expand Down
4 changes: 3 additions & 1 deletion buildout.d/versions.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[versions]
setuptools = 44.1.1
zc.buildout = 2.13.3
#python 2 ...
# python 2 ...
backports.functools-lru-cache = 1.6.4
traitlets = 4.3.3
future = 0.18.2
six = 1.16.0
# misc
plone.formwidget.namedfile = 2.0.6

Expand Down
10 changes: 7 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def read(*rnames):

setup(
name='collective.eeafaceted.z3ctable',
version='2.25.dev0',
version='2.27.dev0',
description="Package proposant un type de colonne compatible avec eea.facetednavigation",
long_description=long_description,
# Get more from http://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand All @@ -25,8 +25,13 @@ def read(*rnames):
"Framework :: Plone :: 4.3",
"Framework :: Plone :: 5.0",
"Framework :: Plone :: 5.1",
"Framework :: Plone :: 6.0",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
],
keywords='Python Zope Plone',
author='IMIO',
Expand All @@ -41,8 +46,7 @@ def read(*rnames):
install_requires=[
'Plone',
'collective.excelexport',
'eea.facetednavigation<16.0',
'imio.helpers',
'eea.facetednavigation>=16.0',
'plone.api>=1.3.0',
'plone.formwidget.namedfile>=2.0.2',
'setuptools',
Expand Down
1 change: 1 addition & 0 deletions src/collective/eeafaceted/z3ctable/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
permission="zope2.View"
/>

<include package="eea.facetednavigation" file="permissions.zcml" />
<browser:page
for="eea.facetednavigation.interfaces.IFacetedNavigable"
name="default_collection_widgets.xml"
Expand Down
9 changes: 4 additions & 5 deletions src/collective/eeafaceted/z3ctable/browser/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from z3c.table.table import SequenceTable
from zope.component import getAdapters
from zope.component import queryMultiAdapter
from zope.interface import implements
from zope.interface import implementer

import html
import logging
Expand Down Expand Up @@ -112,15 +112,14 @@ def renderCell(self, item, column, colspan=0):
return renderedCell


@implementer(IFacetedTable)
class FacetedTableView(BrowserView, ExtendedCSSTable):

implements(IFacetedTable)

# workaround so z3c.table does not manage batching
startBatchingAt = 9999
cssClassEven = u'odd'
cssClassOdd = u'even'
cssClasses = {'table': 'faceted-table-results listing nosort'}
cssClasses = {'table': 'faceted-table-results table table-striped table-bordered nosort'}
ignoreColumnWeight = False # when set to True, keep columns ordered as returned by '_getViewFields'
table_id = 'faceted_table'
row_id_prefix = 'row_'
Expand All @@ -141,7 +140,7 @@ def render_table(self, batch):
self.update(batch)
try:
return self.render()
except Exception, exc:
except Exception as exc:
# in case an error occured, catch it or it freezes the web page
# because faceted JS disable page and error raised does not unlock
traceback.print_exc(None)
Expand Down
21 changes: 12 additions & 9 deletions src/collective/eeafaceted/z3ctable/columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from collective.eeafaceted.z3ctable import _
from collective.eeafaceted.z3ctable.interfaces import IFacetedColumn
from collective.eeafaceted.z3ctable.utils import base_getattr
from collective.eeafaceted.z3ctable.utils import get_user_fullname
from collective.excelexport.exportables.dexterityfields import get_exportable_for_fieldname
from datetime import date
from imio.helpers.content import base_getattr
from imio.helpers.content import get_user_fullname
from plone import api
from Products.CMFPlone.utils import base_hasattr
from Products.CMFPlone.utils import safe_unicode
Expand All @@ -18,7 +18,7 @@
from zope.component import getMultiAdapter
from zope.component import queryUtility
from zope.i18n import translate
from zope.interface import implements
from zope.interface import implementer
from zope.schema.interfaces import IVocabularyFactory

import html
Expand All @@ -38,6 +38,8 @@
api.env.get_distribution('collective.z3cform.datagridfield')
from collective.z3cform.datagridfield.datagridfield import DataGridField
HAS_Z3CFORM_DATAGRIDFIELD = True
except ImportError:
HAS_Z3CFORM_DATAGRIDFIELD = False
except pkg_resources.DistributionNotFound:
HAS_Z3CFORM_DATAGRIDFIELD = False

Expand All @@ -46,10 +48,9 @@
EMPTY_DATE = date(1950, 1, 1)


@implementer(IFacetedColumn)
class BaseColumn(column.GetAttrColumn):

implements(IFacetedColumn)

sort_index = None
# as we use setUpColumns, weight is 1 for every columns
weight = 1
Expand All @@ -69,7 +70,10 @@ class BaseColumn(column.GetAttrColumn):
def getValue(self, item):
""" """
if self.the_object:
return safe_unicode(base_getattr(self._getObject(item), self.attrName))
attr = safe_unicode(base_getattr(self._getObject(item), self.attrName))
if callable(attr):
return attr()
return attr
else:
return super(BaseColumn, self).getValue(item)

Expand Down Expand Up @@ -275,8 +279,7 @@ def renderCell(self, item):
value = self.getValue(item)
if not value or value == self.ignored_value:
return u'-'
value = get_user_fullname(value)
return safe_unicode(value)
return safe_unicode(get_user_fullname(value))


class DateColumn(BaseColumn):
Expand Down Expand Up @@ -409,7 +412,7 @@ class AbbrColumn(VocabularyColumn):

def renderCell(self, item):
value = self.getValue(item)
if not value:
if not value or value == self.ignored_value:
return u'-'

# caching when several same values in same column
Expand Down
2 changes: 0 additions & 2 deletions src/collective/eeafaceted/z3ctable/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
<five:registerPackage package="." initialize=".initialize" />

<!-- Include configuration for dependencies listed in setup.py -->
<includeDependencies package="." />
<include zcml:condition="installed imio.actionspanel" package="imio.actionspanel"/>
<include package="imio.helpers"/>
<include zcml:condition="installed imio.prettylink" package="imio.prettylink"/>

<!-- Include sub-packages that use their own configure.zcml files. -->
Expand Down
38 changes: 25 additions & 13 deletions src/collective/eeafaceted/z3ctable/profiles.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,37 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:zcml="http://namespaces.zope.org/zcml"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
xmlns:five="http://namespaces.zope.org/five"
i18n_domain="collective.eeafaceted.collectionwidget">

<genericsetup:registerProfile
zcml:condition="have plone-5"
zcml:condition="have plone-60"
name="default"
directory="profiles/plone5"
directory="profiles/plone6"
title="collective.eeafaceted.z3ctable"
description="Extension profile for collective.eeafaceted.z3ctable."
provides="Products.GenericSetup.interfaces.EXTENSION" />

<genericsetup:registerProfile
zcml:condition="not-have plone-5"
name="default"
directory="profiles/plone4"
title="collective.eeafaceted.z3ctable"
description="Extension profile for collective.eeafaceted.z3ctable."
provides="Products.GenericSetup.interfaces.EXTENSION" />


<configure zcml:condition="not-have plone-60">
<genericsetup:registerProfile
zcml:condition="have plone-5"
name="default"
directory="profiles/plone5"
title="collective.eeafaceted.z3ctable"
description="Extension profile for collective.eeafaceted.z3ctable."
provides="Products.GenericSetup.interfaces.EXTENSION" />
</configure>

<configure zcml:condition="not-have plone-60">
<configure zcml:condition="not-have plone-5">
<genericsetup:registerProfile
name="default"
directory="profiles/plone4"
title="collective.eeafaceted.z3ctable"
description="Extension profile for collective.eeafaceted.z3ctable."
provides="Products.GenericSetup.interfaces.EXTENSION" />
</configure>
</configure>

<genericsetup:registerProfile
name="universal"
directory="profiles/common"
Expand Down Expand Up @@ -55,5 +67,5 @@
description=""
import_steps="jsregistry" />
</genericsetup:upgradeSteps>

</configure>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
<version>3</version>
<dependencies>
<dependency>profile-eea.facetednavigation:default</dependency>
<dependency>profile-imio.helpers:default</dependency>
</dependencies>
</metadata>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<metadata>
<version>3</version>
<dependencies>
<dependency>profile-collective.eeafaceted.z3ctable:universal</dependency>
</dependencies>
</metadata>
19 changes: 19 additions & 0 deletions src/collective/eeafaceted/z3ctable/profiles/plone6/registry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<registry>

<records interface="Products.CMFPlone.interfaces.IBundleRegistry"
prefix="plone.bundles/faceted-vars-z3ctable">
<value key="enabled">True</value>
<value key="jscompilation">collective_eeafaceted_z3ctable_js_variables.js</value>
<value key="load_defer">False</value>
<value key="load_async">False</value>
</records>

<records interface="Products.CMFPlone.interfaces.IBundleRegistry"
prefix="plone.bundles/faceted-z3ctable">
<value key="enabled">True</value>
<value key="jscompilation">++resource++collective.eeafaceted.z3ctable/collective.eeafaceted.z3ctable.js</value>
<value key="load_defer">False</value>
<value key="load_async">False</value>
</records>
</registry>
12 changes: 12 additions & 0 deletions src/collective/eeafaceted/z3ctable/tests/test_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from collective.eeafaceted.z3ctable.columns import DateColumn
from collective.eeafaceted.z3ctable.columns import DxWidgetRenderColumn
from collective.eeafaceted.z3ctable.columns import ElementNumberColumn
from collective.eeafaceted.z3ctable.columns import EMPTY_STRING
from collective.eeafaceted.z3ctable.columns import I18nColumn
from collective.eeafaceted.z3ctable.columns import IconsColumn
from collective.eeafaceted.z3ctable.columns import MemberIdColumn
Expand Down Expand Up @@ -395,6 +396,12 @@ def test_AbbrColumn(self):
u"<abbr title='Full existing value 1'>Existing v\xe9lue 1, </abbr>"
u"<abbr title='unexisting_key'>unexisting_key, </abbr>"
u"<abbr title='Full existing value 2'>Existing v\xe9lue 2</abbr>")
# ignored_value
self.assertEqual(column.ignored_value, EMPTY_STRING)
self.eea_folder.setTitle(EMPTY_STRING)
self.eea_folder.reindexObject(idxs=['Title', ])
brain = self.portal.portal_catalog(UID=self.eea_folder.UID())[0]
self.assertEqual(column.renderCell(brain), u'-')

def test_TheObjectVocabularyColumn(self):
"""VocabularyColumn where we awake object to get attrName attribute."""
Expand All @@ -407,6 +414,11 @@ def test_TheObjectVocabularyColumn(self):
column.vocabulary = "collective.eeafaceted.z3ctable.testingvocabulary"
column.full_vocabulary = "collective.eeafaceted.z3ctable.testingfullvocabulary"
self.assertEqual(column.renderCell(brain), u"Existing v\xe9lue 1")
# if a callable is defined, it is called
self.eea_folder.setTitle([u'existing_key1', u'existing_key2'])
self.eea_folder.reindexObject()
column.attrName = 'Title'
self.assertEqual(column.renderCell(brain), u'Existing v\xe9lue 1, Existing v\xe9lue 2')
# will raise if attrName does not exist
column.attrName = "unknown"
self.assertEqual(column.renderCell(brain), u'-')
Expand Down
6 changes: 3 additions & 3 deletions src/collective/eeafaceted/z3ctable/tests/vocabularies.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# encoding: utf-8

from plone.memoize.instance import memoize
from zope.interface import implements
from zope.interface import implementer
from zope.schema.interfaces import IVocabularyFactory
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary


@implementer(IVocabularyFactory)
class TestingVocabulary(object):
implements(IVocabularyFactory)

@memoize
def __call__(self, context):
Expand All @@ -23,8 +23,8 @@ def __call__(self, context):
TestingVocabularyFactory = TestingVocabulary()


@implementer(IVocabularyFactory)
class TestingFullVocabulary(object):
implements(IVocabularyFactory)

@memoize
def __call__(self, context):
Expand Down
Loading
Loading