Skip to content

Add get_spec to IPackageOverrides#3792

Merged
mmerickel merged 11 commits intoPylons:mainfrom
luhn:override-get-spec
Feb 24, 2026
Merged

Add get_spec to IPackageOverrides#3792
mmerickel merged 11 commits intoPylons:mainfrom
luhn:override-get-spec

Conversation

@luhn
Copy link
Copy Markdown
Contributor

@luhn luhn commented Aug 25, 2025

While working on #3791, I ran into an issue: The cache buster was diving into the guts of PackageOverrides, stymying my attempts to refactor that.

pathspec = f'{pkg_name}:{pkg_subpath}{subpath}'
overrides = registry.queryUtility(IPackageOverrides, name=pkg_name)
if overrides is not None:
resource_name = posixpath.join(pkg_subpath, subpath)
sources = overrides.filtered_sources(resource_name)
for source, filtered_path in sources:
rawspec = source.get_path(filtered_path)
if hasattr(source, 'pkg_name'):
rawspec = f'{source.pkg_name}:{rawspec}'
break

In particular, get_path and pkg_name should be considered private members PackageAssetSource/FSAssetSource, because they are undocumented and aren't directly tested.

This PR is an attempt to formalize those into a public, tested method called get_spec.

I also added get_spec to the IPackageOverrides interface. This seemed necessary, as if we want to call that method after querying for the utility, it should be in the interface.

This comes with some minor behavior changes as well: The original _bust_asset_path implementation did not check for file existence (it always took the first matching override source), whereas the new implementation does in order to match the behavior of overrides elsewhere.

@luhn
Copy link
Copy Markdown
Contributor Author

luhn commented Feb 24, 2026

Tests are passing 👍

@mmerickel mmerickel merged commit 504c050 into Pylons:main Feb 24, 2026
26 checks passed
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