This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

ZODB Mount Point

This package provides a very simple implementation of a mount point for an object in another ZODB connection. If you have multiple connections defined in your zope.conf configuration file or multiple databases defined in your Python code, you can use this package to mount any object from any database at any location of another database.

Let’s start by creating two databases in the typical Zope 3 application layout:

>>> from ZODB.tests.test_storage import MinimalMemoryStorage
>>> from ZODB import DB
>>> from import rootFolder, Folder
>>> import transaction
>>> dbmap = {}
>>> db1 = DB(MinimalMemoryStorage(), database_name='db1', databases=dbmap)
>>> conn1 =
>>> conn1.root()['Application'] = rootFolder()
>>> db2 = DB(MinimalMemoryStorage(), database_name='db2', databases=dbmap)
>>> conn2 =
>>> conn2.root()['Application'] = rootFolder()
>>> transaction.commit()

Let’s now add a sub-folder to the second database, which will serve as the object which we wish to mount:

>>> conn2.root()['Application']['Folder2-1'] = Folder()
>>> transaction.commit()

We can now create a mount point:

>>> from z3c.mountpoint import mountpoint
>>> mountPoint = mountpoint.MountPoint(
...     'db2', objectPath=u'/Folder2-1', objectName=u'F2-1')

The first argument to the constructor is the connection name of the database, the second argument is the path to the mounted object within the mounted DB and the object name is the name under which the object is mounted.

Now we can add the mount point to the first database:

>>> conn1.root()['Application']['mp'] = mountPoint
>>> transaction.commit()

We can now access the mounted object as follows:

>>> conn1.root()['Application']['mp'].object
< object at ...>

Note that the object name is not yet used; it is for traversal only.


So let’s have a look at the traversal next. Before being able to traverse, we need to register the special mount point traverser:

>>> import zope.component
>>> zope.component.provideAdapter(mountpoint.MountPointTraverser)

We should now be able to traverse to the mounted object now:

>>> from zope.publisher.browser import TestRequest
>>> req = TestRequest()
>>> from zope.traversing.publicationtraverse import PublicationTraverser
>>> traverser = PublicationTraverser()
>>> traverser.traversePath(req, conn1.root()['Application'], 'mp/F2-1')
< object at ...>

When we add a new object remotely, it available via the mount point as well:

>>> conn2.root()['Application']['Folder2-1']['Folder2-1.1'] = Folder()
>>> transaction.commit()
>>> tuple(traverser.traversePath(
...    req, conn1.root()['Application'], 'mp/F2-1').keys())

Now, by default the objects refer to their original path:

>>> f211 = traverser.traversePath(
...    req, conn1.root()['Application'], 'mp/F2-1/Folder2-1.1')
>>> from zope.traversing.browser import absoluteurl
>>> absoluteurl.absoluteURL(f211, req)

This package solves that problem by wrapping all object by a special remote location proxy and providing a special wrapping traverser for those proxies:

>>> from z3c.mountpoint import remoteproxy
>>> zope.component.provideAdapter(remoteproxy.RemoteLocationProxyTraverser)
>>> f211 = traverser.traversePath(
...    req, conn1.root()['Application'], 'mp/F2-1/Folder2-1.1')
>>> absoluteurl.absoluteURL(f211, req)

Updating the Mount Point

Whenever any attribute on the mount point is modified, the mount object is updated. For example, when the object path is changed, the object is adjusted as well. This is done with an event subscriber:

>>> mountPoint.objectPath = u'/Folder2-1/Folder2-1.1'
>>> modifiedEvent = object()
>>> mountpoint.updateMountedObject(mountPoint, modifiedEvent)
>>> f211 == mountPoint.object

Change log

0.1 (2010-08-03)

  • Initial release.
Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
z3c.mountpoint-0.1.tar.gz (8.8 kB) Copy SHA256 Checksum SHA256 Source Aug 3, 2010

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting