Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython

repoze.bfg.traversaladapter is unavailable in PyPM, because there aren't any builds for it in the package repositories. Click the linked icons to find out why.

 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1 Failed View build log
Windows (64-bit)
0.1 Failed View build log
Mac OS X (10.5+)
0.1 Failed View build log
Linux (32-bit)
0.1 Failed View build log
Linux (64-bit)
0.1 Failed View build log
 
Links
License
BSD-derived (http://www.repoze.org/LICENSE.txt)
Lastest release
version 0.1 on Jan 5th, 2011

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

System Message: ERROR/3 (<string>, line 16)

Inconsistent literal block quoting.

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

System Message: WARNING/2 (<string>, line 24)

Literal block expected; none found.

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

System Message: ERROR/3 (<string>, line 31)

Inconsistent literal block quoting.

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

System Message: ERROR/3 (<string>, line 40)

Inconsistent literal block quoting.

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

System Message: WARNING/2 (<string>, line 53)

Literal block expected; none found.

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.

repoze.bfg.traversaladapter Changelog

0.1
  • Initial release (based on repoze.bfg.traversalwrapper rev. 0.3).

Subscribe to package updates

Last updated Jan 5th, 2011

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.