Skip to main content

repoze.bfg.traversaladapter

An alternate implementation of the repoze.bfg.interfaces.ITraverserFactory (a “traverser”) which allows you to register an adapter factory for the type or interface(s) of objects encountered during traversal. This is a generalization of the repoze.bfg.traversalwrapper package which automatically wraps each traversed object into a location-aware proxy.

To enable this custom traverser factory, you need to add a dependency on repoze.bfg.traversaladapter to your application and replace the default traverser factory in the configure.zcml configuration file like this:

<adapter
    factory="repoze.bfg.traversaladapter.ModelGraphTraverser"
    provides="repoze.bfg.interfaces.ITraverserFactory"
    for="*"
    />

Given a simple factory for adapters for a model class mymodule.Foo defined in the module mymodule like this

def foo_factory(foo, parent, name):
    return FooAdapter(foo, parent, name)

you could then register foo_factory as a traversal adapter factory as follows:

<adapter
    factory="mymodule.foo_factory"
    provides="repoze.bfg.traversaladapter.ITraversalAdapterFactory"
    for="mymodule.Foo"
    />

If Foo was implementing the interface mymodule.IFoo, the following registration would also work:

<adapter
    factory="mymodule.foo_factory"
    provides="repoze.bfg.traversaladapter.ITraversalAdapterFactory"
    for="mymodule.IFoo"
    />

During traversal of your repoze.bfg application, each object of type Foo will then automatically be wrapped in a FooAdapter instance.

Note that the registered factory always gets the current model object, its parent and its name passed as arguments. If your FooAdapter class was set up to receive a Foo instance, a parent object, and a name string in its constructor like so

class FooAdapter(object):
    def __init__(self, foo, parent, name):
        self.foo = foo
        self.parent = parent
        self.name = name

you could register the adapter class itself as the adapter factory.

See the repoze.bfg.traversaladapter.tests.TraversalAdapterTests module for further examples.

Metadata

Release files for repoze.bfg.traversaladapter 0.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 repoze.bfg.traversaladapter 0.1
File Size Uploaded Provenance Actions
repoze.bfg.traversaladapter-0.1.tar.gz 5.9 kB Without provenance Details for repoze.bfg.traversaladapter-0.1.tar.gz

Release files / repoze.bfg.traversaladapter-0.1.tar.gz

Download URL repoze.bfg.traversaladapter-0.1.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5b9d78f4aee64eae46424d26e3f55ef476a9f6f2924fd01602e569b428716f48
BLAKE2b-256 checksum
How to use checksums
68f9ea3e67dcf4d0f10bf49c2a632d7eb649ca26fae6c6e5d3e5ca6d971be109
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for repoze.bfg.traversaladapter 0.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.

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.

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file No provenance

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