collective.complexrecordsproxy
Providing a proxy class for plone.registry allowing IObject fields to be stored as separate records using the plone.registry collection support.
Motivation
With z3c.form it is possible to create forms allowing users to create and edit lists of complex records: a settings schema with an Object field, or a Tuple / List of Object fields.
plone.registry can't store these fields as records. Its documentation explains why:
To avoid potentially breaking the registry with persistent references to symbols that may go away, we purposefully limit the number of fields supported.
But a complex record boils down to simple native types in the end. ComplexRecordsProxy stores each field of each complex record as a separate registry record, with the collection support of plone.registry, so the registry only holds native types.
Usage
Register the simple fields of the schema as records, omitting the complex ones, and read the settings through ComplexRecordsProxy:
from collective.complexrecordsproxy import ComplexRecordsProxy
from plone.registry.interfaces import IRegistry
from zope import schema
from zope.component import getUtility
from zope.interface import Interface
class IAddress(Interface):
street = schema.TextLine(title="Street")
city = schema.TextLine(title="City", required=False)
class ISettings(Interface):
title = schema.TextLine(title="Title", required=False)
address = schema.Object(title="Address", schema=IAddress, required=False)
addresses = schema.Tuple(
title="Addresses",
value_type=schema.Object(schema=IAddress),
required=False,
missing_value=(),
)
registry = getUtility(IRegistry)
registry.registerInterface(ISettings, omit=("address", "addresses"))
settings = registry.forInterface(
ISettings, omit=("address", "addresses"), factory=ComplexRecordsProxy
)
settings.addresses = (address1, address2) # objects providing IAddress
[address.street for address in settings.addresses]
- An
Objectfieldaddressis stored under<IAddress identifier>/address.<field name>. - A
TupleorListofObjectfieldaddressesis stored under<IAddress identifier>.addresses/r0.<field name>,r1, etc. Setting the field replaces all its items. - Reading a complex field returns
ComplexRecordsProxyobjects, not the objects that were set. ATupleorListfield returns them in a mapping values view: iterate over it, it can't be indexed. A complex field without records returns themissing_valueof the field.
collective.autopublishing uses it for its control panel settings.
Compatibility
Version 2.x supports Plone 6.1 and 6.2, on Python 3.10 to 3.13.
For Plone 4.3 to 6.0 and Python 2.7, use collective.complexrecordsproxy 1.1.
Installation
Add collective.complexrecordsproxy to the dependencies of your package. It is a library, not an add-on: there is no ZCML to load and nothing to activate.
Development
Requires uv. This installs the package with Plone 6.2.3 in .venv (use PLONE_VERSION=6.1.6 make install for another version) and the prek git hook. Plone is not a dependency of the package: the Makefile adds Products.CMFPlone and plone.app.contenttypes for the development instance.
make install
make start # Plone on http://localhost:8080 (admin / admin)
make console # Python console with the Zope application as `app`
Tests
Tests run through tox, as the CI does:
make test # Plone 6.2.3
uvx --with tox-uv tox -e py312-plone61 # one Plone / Python combination
make test-all # lint, every combination, dependencies
Without tox:
.venv/bin/zope-testrunner --test-path=src -s collective.complexrecordsproxy
Lint
make check # format then lint (pyupgrade, isort, black, flake8...)
.editorconfig, .flake8, .gitignore, .pre-commit-config.yaml, tox.ini,
.github/ and the tool sections of pyproject.toml are generated by
plone.meta: change .meta.toml, then run
uvx --from plone.meta config-package --no-commit --branch current ..
Release
make release # zest.releaser fullrelease, run through uvx
Contribute
- Issue Tracker: https://github.com/collective/collective.complexrecordsproxy/issues
- Source Code: https://github.com/collective/collective.complexrecordsproxy
License
The project is licensed under the GPLv2 or later.
Contributors
- Sune Broendum Woeller
- Tom Gross
- Christophe Boulanger
- Laurent Lasudry
Changelog
2.0.0 (2026-11-23)
-
Breaking: replace the
pkg_resourcesnamespace ofcollectivewith a PEP 420 native namespace, and move the package to asrc/layout. Support Plone 6.1 and 6.2 only, on Python 3.10 to 3.13. Use 1.1 for Plone 4.3 to 6.0 and Python 2.7. [remdub] -
Add unit tests for
ComplexRecordsProxy(the package had none), and list it in__all__. [remdub] -
Configure the package with plone.meta 2.12.0 (test matrix on Plone 6.2.3 and 6.1), move its metadata to
pyproject.toml, convert the documentation to Markdown and add a development environment on Plone 6.2.3 with uv. [remdub]
1.1 (2022-01-13)
- Add Python 3 & Plone 5.2 / 6.0 compatibility [boulch, laulaz]
1.0 (2016-01-29)
- Initial release [sunew, tomgross]
Metadata
Release files for collective.complexrecordsproxy 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| collective_complexrecordsproxy-2.0.0.tar.gz | 15.7 kB | Without provenance | Details for collective_complexrecordsproxy-2.0.0.tar.gz |
Release files / collective_complexrecordsproxy-2.0.0.tar.gz
| Download URL | collective_complexrecordsproxy-2.0.0.tar.gz |
|---|---|
| Size | 15.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a6f90d519657571f9923814667868a61df378bb8330114dccaee2eebdb3261e
|
|
BLAKE2b-256 checksum How to use checksums |
598a50174e5a234a19c9d71643063fa4281411d7bc6fb3db5275f1be510e2d27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Security for collective.complexrecordsproxy 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.