Skip to content

URB-3702: Set up cron4plone for notice import - #596

Open
daggelpop wants to merge 2 commits into
2.9.xfrom
URB-3702_cron4plone-notice-import
Open

URB-3702: Set up cron4plone for notice import#596
daggelpop wants to merge 2 commits into
2.9.xfrom
URB-3702_cron4plone-notice-import

Conversation

@daggelpop

@daggelpop daggelpop commented Jul 9, 2026

Copy link
Copy Markdown
Contributor
  • Add cron4plone instruction for notice import
  • Switch NOTICe API default URL to production

Note: metadata version goes from 2916 to 2918 because 2917 was forgotten in another PR.

Summary by CodeRabbit

  • New Features

    • Added an automatic hourly import task for notice data.
    • Updated the default notice API endpoint to use the production service.
    • Included the new notice import setup in the next upgrade step.
  • Chores

    • Bumped the package metadata version to reflect the latest upgrade.

@daggelpop
daggelpop requested a review from mpeeters July 9, 2026 13:40
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a migration upgrade step that registers a cron4plone job for portal/@@import-from-notice, updates the default cron job list in setuphandlers, switches the NOTICe API default URL from staging to production, bumps the profile metadata version, and adds a corresponding ZCML upgrade step entry and news fragment.

Changes

Cron4plone Notice Import Setup

Layer / File(s) Summary
Production API URL default
src/Products/urban/browser/notice_settings.py
The INoticeSettings.url default value is changed from the staging API endpoint to the production API endpoint.
Upgrade step to register cron4plone notice import
src/Products/urban/migration/update_290.py, src/Products/urban/migration/upgrades_290.zcml, src/Products/urban/profiles/default/metadata.xml
Adds setup_cron4plone_notice_import(context), which queries the cron4plone_config utility and appends the portal/@@import-from-notice cron expression if not already present; wires this via a new generic setup upgrade step (2917→2918) and bumps the profile metadata version to 2918.
Default cron jobs list and release notes
src/Products/urban/setuphandlers.py, news/URB-3702.feature
Adds an hourly portal/@@import-from-notice entry to the default cron job list and documents the change (production API switch, cron import setup) in the news fragment.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GenericSetup
  participant update_290
  participant ICronConfiguration

  GenericSetup->>update_290: run setup_cron4plone_notice_import(context)
  update_290->>ICronConfiguration: queryUtility(cron4plone_config)
  ICronConfiguration-->>update_290: cron_cfg
  update_290->>update_290: check for import-from-notice cron entry
  update_290->>ICronConfiguration: append entry and update cron_cfg.cronjobs
Loading

Possibly related PRs

  • IMIO/Products.urban#535: Adds/enables the portal/@@import-from-notice cron job that triggers the notice import code updated in this related PR.
  • IMIO/Products.urban#582: Enables the hourly portal/@@import-from-notice cron job that exercises the notice notification handling logic updated in this related PR.
  • IMIO/Products.urban#589: Sets up the portal/@@import-from-notice scheduling that connects to the notice import notification routing extended in this related PR.

Suggested reviewers: mpeeters

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: setting up cron4plone for notice import.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch URB-3702_cron4plone-notice-import

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/Products/urban/migration/update_290.py (2)

648-662: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider using the module-level logger instead of creating a new one.

The function creates logging.getLogger("urban: Setup cron4plone notice import") at line 651, while a module-level logger = logging.getLogger("urban: migrations") already exists at line 30. Using the module-level logger keeps log filtering consistent with other migration steps.

♻️ Proposed refactor
 def setup_cron4plone_notice_import(context):
-    logger = logging.getLogger("urban: Setup cron4plone notice import")
-
     cron_cfg = queryUtility(
         ICronConfiguration, name="cron4plone_config", context=api.portal.get()
     )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Products/urban/migration/update_290.py` around lines 648 - 662, The
setup_cron4plone_notice_import migration step creates its own logger instead of
using the existing module-level logger, which makes migration logging
inconsistent. Update this function to reuse the module-level logger already
defined in the migration module rather than calling logging.getLogger again, and
keep the existing info message behavior unchanged.

659-659: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use unpacking instead of list concatenation.

Ruff flags list(cron_cfg.cronjobs) + [line_to_add] as RUF005. Prefer [*list(cron_cfg.cronjobs), line_to_add] for idiomatic Python.

♻️ Proposed fix
-        new_list = list(cron_cfg.cronjobs) + [line_to_add]
+        new_list = [*list(cron_cfg.cronjobs), line_to_add]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Products/urban/migration/update_290.py` at line 659, The cronjobs list
construction in the migration logic should use unpacking instead of list
concatenation to satisfy Ruff RUF005. Update the assignment in the code path
that builds new_list from cron_cfg.cronjobs and line_to_add so it uses the
unpacking form, keeping the same behavior while making the expression idiomatic.
Use the existing cron_cfg.cronjobs and new_list symbols to locate the change.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/Products/urban/migration/update_290.py`:
- Around line 648-662: The setup_cron4plone_notice_import migration step creates
its own logger instead of using the existing module-level logger, which makes
migration logging inconsistent. Update this function to reuse the module-level
logger already defined in the migration module rather than calling
logging.getLogger again, and keep the existing info message behavior unchanged.
- Line 659: The cronjobs list construction in the migration logic should use
unpacking instead of list concatenation to satisfy Ruff RUF005. Update the
assignment in the code path that builds new_list from cron_cfg.cronjobs and
line_to_add so it uses the unpacking form, keeping the same behavior while
making the expression idiomatic. Use the existing cron_cfg.cronjobs and new_list
symbols to locate the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b4c5e572-373a-457c-be37-8c8b9e847c52

📥 Commits

Reviewing files that changed from the base of the PR and between e9f04e4 and a2b7f73.

📒 Files selected for processing (6)
  • news/URB-3702.feature
  • src/Products/urban/browser/notice_settings.py
  • src/Products/urban/migration/update_290.py
  • src/Products/urban/migration/upgrades_290.zcml
  • src/Products/urban/profiles/default/metadata.xml
  • src/Products/urban/setuphandlers.py

@mpeeters mpeeters left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, Can you please fix conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants