Skip to content

refactor(brain): catalog-independent PGCatalogBrain#156

Merged
jensens merged 1 commit into
mainfrom
fix/brain-remove-catalog-ref
Apr 21, 2026
Merged

refactor(brain): catalog-independent PGCatalogBrain#156
jensens merged 1 commit into
mainfrom
fix/brain-remove-catalog-ref

Conversation

@jensens
Copy link
Copy Markdown
Member

@jensens jensens commented Apr 21, 2026

Summary

  • Drops _catalog from PGCatalogBrain.__slots__ so brains can be cached across request boundaries without carrying per-request references
  • getURL uses zope.globalrequest.getRequest() only — no catalog lookup
  • getObject / _unrestrictedGetObject resolve the traversal root via getSite().getPhysicalRoot() with a request.PARENTS[-1] fallback (new _traversal_root() module helper)
  • Catalog ref moves onto CatalogSearchResults (transient), where ZODB prefetch still needs it for _p_jar
  • __init__(self, row, catalog=None) accepts the kwarg for backwards API compatibility but ignores it

Why

Per-brain catalog references interfere with brain caching and prevent catalog-independent reuse. Addresses the feedback on the prior prefetch work: prefetch belongs on the result set, not on individual brains.

Test plan

  • Full test suite: 1451 passed / 23 skipped / 0 failed
  • Brain tests rewritten to mock plone.pgcatalog.brain._traversal_root instead of wiring a fake catalog
  • New tests cover getURL via getRequest() path and the no-request fallback to getPath()

🤖 Generated with Claude Code

Catalog-independent brains cache cleanly across request boundaries.
Catalog reference moves onto the transient CatalogSearchResults (needed
there for ZODB prefetch _p_jar access), not onto individual brains.

- getURL now uses only zope.globalrequest.getRequest(); no catalog lookup
- getObject / _unrestrictedGetObject resolve the traversal root via
  getSite().getPhysicalRoot() with a request.PARENTS fallback
- PGCatalogBrain.__slots__ drops _catalog; __init__ accepts catalog=None
  for backwards API compatibility but ignores it
- Brain tests mock plone.pgcatalog.brain._traversal_root instead of
  wiring a fake catalog onto the brain

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jensens jensens merged commit 8f11164 into main Apr 21, 2026
5 checks passed
@jensens jensens deleted the fix/brain-remove-catalog-ref branch April 21, 2026 08:12
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.

1 participant