Skip to main content

ObjectPath

This package contains two things:

  • the z3c.objpath.interfaces.IObjectPath interface.

  • some helper functions to construct (relative) object paths, in z3c.objpath.path.

The idea is that a particular application can implement a utility that fulfills the IObjectPath interface, so that it is possible to construct paths to objects in a uniform way. The implementation may be done with zope.traversing, but in some cases you want application-specific object paths. In this case, the functions in z3c.objpath.path might be useful.

We’ll have a simple item:

>>> class Item(object):
...   __name__ = None
...   __parent__ = None
...   def __repr__(self):
...     return '<Item %s>' % self.__name__

Let’s create a simple container-like object:

>>> class Container(Item):
...   def __init__(self):
...     self._d = {}
...   def __setitem__(self, name, obj):
...     self._d[name] = obj
...     obj.__name__ = name
...     obj.__parent__ = self
...   def __getitem__(self, name):
...     return self._d[name]
...   def __repr__(self):
...     return '<Container %s>' % self.__name__

Now let’s create a structure:

>>> root = Container()
>>> root.__name__ = 'root'
>>> data = root['data'] = Container()
>>> a = data['a'] = Container()
>>> b = data['b'] = Container()
>>> c = data['c'] = Item()
>>> d = a['d'] = Item()
>>> e = a['e'] = Container()
>>> f = e['f'] = Item()
>>> g = b['g'] = Item()

We will now exercise two functions, path and resolve, which are inverses of each other:

>>> from z3c.objpath import path, resolve

We can create a path to a from root:

>>> path(root, a)
'/root/data/a'

We can also resolve it again:

>>> resolve(root, '/root/data/a')
<Container a>

We can also create a path to a from data:

>>> path(data, a)
'/data/a'

And resolve it again:

>>> resolve(data, '/data/a')
<Container a>

We can make a deeper path:

>>> path(root, f)
'/root/data/a/e/f'

And resolve it:

>>> resolve(root, '/root/data/a/e/f')
<Item f>

The path ‘/’ leads to the root object:

>>> resolve(root, '/')
<Container root>

We get an error if we cannot construct a path:

>>> path(e, a)
Traceback (most recent call last):
 ...
ValueError: Cannot create path for <Container a>

We also get an error if we cannot resolve a path:

>>> resolve(root, '/root/data/a/f/e')
Traceback (most recent call last):
 ...
ValueError: Cannot resolve path /root/data/a/f/e

z3c.objpath changes

3.1 (2026-11-26)

  • Add support for Python 3.15.

  • Drop support for Python 3.10.

  • Move package metadata from setup.py to pyproject.toml.

  • Add support for Python 3.14.

  • Drop support for Python 3.9.

3.0 (2025-04-14)

  • Replace pkg_resources namespace with PEP 420 native namespace.

2.1 (2025-04-07)

  • Add support for Python 3.12, 3.13.

  • Drop support for Python 3.7, 3.8.

2.0 (2023-08-21)

  • Drop support for Python 2.7, 3.5, 3.6.

1.3 (2022-12-02)

  • Add support for Python 3.7, 3.8, 3.9, 3.10, 3.11.

1.2 (2018-06-14)

  • Add support for Python 3.5, 3.6, PyPy and PyPy3.

1.1 (2012-10-13)

  • Add name space declaration for z3c.

  • Added a test extra, as test require zope.testing.

1.0 (2008-04-15)

  • Initial public release.

Metadata

Release files for z3c.objpath 3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for z3c.objpath 3.1
File Size Uploaded Provenance Actions
z3c_objpath-3.1.tar.gz 7.8 kB With provenance Details for z3c_objpath-3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for z3c.objpath 3.1
File Interpreter ABI Platform Actions
z3c_objpath-3.1-py3-none-any.whl Python 3 none any Details for z3c_objpath-3.1-py3-none-any.whl

Total release size: 14.5 kB

Release files / z3c_objpath-3.1.tar.gz

Download URL z3c_objpath-3.1.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6c30b4f6f5823c2b062036dbc62492d44025a9234d20df2e188bca31ce46e3e0
BLAKE2b-256 checksum
How to use checksums
36bce0809f5bd39807f26839c3eb53c6b51de377eaca7815fc97ee97b40de557
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / z3c_objpath-3.1-py3-none-any.whl

Download URL z3c_objpath-3.1-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
597a0415a709e471bc2494b1b709054916ba6c2b4ace2184e274c4ad5761b5f9
BLAKE2b-256 checksum
How to use checksums
c36994806c30c891bf5c6c402d020d7003c655e98abad4dd5e920ffd8bdacc25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for z3c.objpath 3.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for z3c_objpath-3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page