Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Changelog
5.1 (unreleased)
----------------

- Nothing changed yet.
- Add registry setting for 'int field'
[espenmn]


5.0 (2023-06-07)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<version>12</version>
<version>13</version>
</metadata>
11 changes: 11 additions & 0 deletions src/collective/collectionfilter/profiles/default/registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
</value>
</record>

<record name="collective.collectionfilter.int_types">
<field type="plone.registry.field.Tuple">
<title>Target Collection Types</title>
<description>A list of fields that are int</description>
<value_type type="plone.registry.field.TextLine" />
</field>
<value>
<element>intfield</element>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a project individual value. The default in the package is empty, so I would initialize it empty here too.

</value>
</record>

<records interface="Products.CMFPlone.interfaces.IResourceRegistry"
prefix="plone.resources/collectionfilter"
remove="True"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<version>13</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update profiles do not need a metadata.xml file.

</metadata>
13 changes: 13 additions & 0 deletions src/collective/collectionfilter/profiles/upgrade-13/registry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<registry>
<record name="collective.collectionfilter.int_types">
<field type="plone.registry.field.Tuple">
<title>Target Collection Types</title>
<description>A list of fields that are int</description>
<value_type type="plone.registry.field.TextLine" />
</field>
<value>
<element>intfield</element>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above -> empty initialization per default

</value>
</record>
</registry>
4 changes: 4 additions & 0 deletions src/collective/collectionfilter/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,7 @@ def upgrade_to_plone6(context):
del registry.records[key]

reapply_profile(context)

def upgrade_registry_13(context):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you only want to reload an existing import_step I'd not do this in python code but in zcml see my change suggestion below.

# Probably not needed
reapply_profile(context)
8 changes: 8 additions & 0 deletions src/collective/collectionfilter/upgrades.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,13 @@
handler=".upgrades.upgrade_to_plone6"
/>

<genericsetup:upgradeStep
title="collective.collectionfilter: Upgrade v12 to v13"
description="upgrade to version 13"
source="12"
destination="13"
profile="collective.collectionfilter:upgrade-13"
handler=".upgrades.upgrade_registry_13"
/>

Comment on lines +103 to 111
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<genericsetup:upgradeStep
title="collective.collectionfilter: Upgrade v12 to v13"
description="upgrade to version 13"
source="12"
destination="13"
profile="collective.collectionfilter:upgrade-13"
handler=".upgrades.upgrade_registry_13"
/>
<genericsetup:upgradeDepends
title="collective.collectionfilter: Upgrade v12 to v13"
description="upgrade to version 13"
source="12"
destination="13"
profile="collective.collectionfilter:default"
import_profile="collective.collectionfilter:upgrade-13"
/>

And the registration of the upgrade profile collective.collectionfilter:upgrade-13 is missing in configure.zcml

</configure>
16 changes: 16 additions & 0 deletions src/collective/collectionfilter/vocabularies.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@

import plone.api

from zope.interface.interfaces import ComponentLookupError


# Use this EMPTY_MARKER for your custom indexer to index empty criterions.
EMPTY_MARKER = "__EMPTY__"
TEXT_IDX = "SearchableText"

# integer ids are stored in the registry
# But not before version upgrade
INTEGER_IDXS = []

GEOLOC_IDX = [
"latitude",
"longitude",
Expand Down Expand Up @@ -140,6 +146,16 @@ def groupby(self):
return self._groupby
self._groupby = {}

# Use 'try' since it broke before update
# Maybe move this code to GroupByCriteria
try:
INTEGER_IDXS = plone.api.portal.get_registry_record(
"collective.collectionfilter.int_types", default=[]
)
except ComponentLookupError:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought registry lookup errors are handled in plone.api ... and please follow the suggestion of the docs:

Always import the top-level package (from plone import api) and then use the module namespace to access the method you want (portal = api.portal.get()).

See https://6.docs.plone.org/plone.api/about.html#design-decisions

INTEGER_IDXS = []


cat = plone.api.portal.get_tool("portal_catalog")
# get catalog metadata schema, but filter out items which cannot be
# used for grouping
Expand Down