{ "info": { "author": "Stephan Richter and the Zope Community", "author_email": "zope-dev@zope.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Web Environment", "Framework :: Zope3", "Intended Audience :: Developers", "License :: OSI Approved :: Zope Public License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP" ], "description": "================\nZODB Mount Point\n================\n\nThis package provides a very simple implementation of a mount point for an\nobject in another ZODB connection. If you have multiple connections defined in\nyour ``zope.conf`` configuration file or multiple databases defined in your\nPython code, you can use this package to mount any object from any database at\nany location of another database.\n\nLet's start by creating two databases in the typical Zope 3 application layout:\n\n >>> from ZODB.tests.test_storage import MinimalMemoryStorage\n >>> from ZODB import DB\n >>> from zope.site.folder import rootFolder, Folder\n >>> import transaction\n\n >>> dbmap = {}\n\n >>> db1 = DB(MinimalMemoryStorage(), database_name='db1', databases=dbmap)\n >>> conn1 = db1.open()\n >>> conn1.root()['Application'] = rootFolder()\n\n >>> db2 = DB(MinimalMemoryStorage(), database_name='db2', databases=dbmap)\n >>> conn2 = db2.open()\n >>> conn2.root()['Application'] = rootFolder()\n\n >>> transaction.commit()\n\nLet's now add a sub-folder to the second database, which will serve as the\nobject which we wish to mount:\n\n >>> conn2.root()['Application']['Folder2-1'] = Folder()\n >>> transaction.commit()\n\nWe can now create a mount point:\n\n >>> from z3c.mountpoint import mountpoint\n >>> mountPoint = mountpoint.MountPoint(\n ... 'db2', objectPath=u'/Folder2-1', objectName=u'F2-1')\n\nThe first argument to the constructor is the connection name of the database,\nthe second argument is the path to the mounted object within the mounted DB\nand the object name is the name under which the object is mounted.\n\nNow we can add the mount point to the first database:\n\n >>> conn1.root()['Application']['mp'] = mountPoint\n >>> transaction.commit()\n\nWe can now access the mounted object as follows:\n\n >>> conn1.root()['Application']['mp'].object\n \n\nNote that the object name is not yet used; it is for traversal only.\n\n\nTraversal\n---------\n\nSo let's have a look at the traversal next. Before being able to traverse, we\nneed to register the special mount point traverser:\n\n >>> import zope.component\n >>> zope.component.provideAdapter(mountpoint.MountPointTraverser)\n\nWe should now be able to traverse to the mounted object now:\n\n >>> from zope.publisher.browser import TestRequest\n >>> req = TestRequest()\n\n >>> from zope.traversing.publicationtraverse import PublicationTraverser\n >>> traverser = PublicationTraverser()\n >>> traverser.traversePath(req, conn1.root()['Application'], 'mp/F2-1')\n \n\nWhen we add a new object remotely, it available via the mount point as well:\n\n >>> conn2.root()['Application']['Folder2-1']['Folder2-1.1'] = Folder()\n >>> transaction.commit()\n\n >>> tuple(traverser.traversePath(\n ... req, conn1.root()['Application'], 'mp/F2-1').keys())\n (u'Folder2-1.1',)\n\nNow, by default the objects refer to their original path:\n\n >>> f211 = traverser.traversePath(\n ... req, conn1.root()['Application'], 'mp/F2-1/Folder2-1.1')\n\n >>> from zope.traversing.browser import absoluteurl\n >>> absoluteurl.absoluteURL(f211, req)\n 'http://127.0.0.1/Folder2-1/Folder2-1.1'\n\nThis package solves that problem by wrapping all object by a special remote\nlocation proxy and providing a special wrapping traverser for those proxies:\n\n >>> from z3c.mountpoint import remoteproxy\n >>> zope.component.provideAdapter(remoteproxy.RemoteLocationProxyTraverser)\n\n >>> f211 = traverser.traversePath(\n ... req, conn1.root()['Application'], 'mp/F2-1/Folder2-1.1')\n >>> absoluteurl.absoluteURL(f211, req)\n 'http://127.0.0.1/mp/F2-1/Folder2-1.1'\n\n\nUpdating the Mount Point\n------------------------\n\nWhenever any attribute on the mount point is modified, the mount object is\nupdated. For example, when the object path is changed, the object is adjusted\nas well. This is done with an event subscriber:\n\n >>> mountPoint.objectPath = u'/Folder2-1/Folder2-1.1'\n\n >>> modifiedEvent = object()\n >>> mountpoint.updateMountedObject(mountPoint, modifiedEvent)\n\n >>> f211 == mountPoint.object\n True\n\n\n\n============\n Change log\n============\n\n0.1 (2010-08-03)\n----------------\n\n* Initial release.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/z3c.mountpoint", "keywords": "zope3 zodb mount mountpoint", "license": "ZPL 2.1", "maintainer": null, "maintainer_email": null, "name": "z3c.mountpoint", "package_url": "https://pypi.org/project/z3c.mountpoint/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/z3c.mountpoint/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/z3c.mountpoint" }, "release_url": "https://pypi.org/project/z3c.mountpoint/0.1/", "requires_dist": null, "requires_python": null, "summary": "Very simple implementation of a mount point for an object in another ZODB connection.", "version": "0.1" }, "last_serial": 802055, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "24136a417a24c294049fdb3df47f529d", "sha256": "b2a8cf5ceef75dea354df7e33335635d2f1f11048e9b10f9e3e07e98a36c6a7c" }, "downloads": -1, "filename": "z3c.mountpoint-0.1.tar.gz", "has_sig": false, "md5_digest": "24136a417a24c294049fdb3df47f529d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8803, "upload_time": "2010-08-03T08:29:46", "url": "https://files.pythonhosted.org/packages/34/5a/980992767d10c9618ecb451a52c0bc8ac8370e88302fa7cef988727d464d/z3c.mountpoint-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "24136a417a24c294049fdb3df47f529d", "sha256": "b2a8cf5ceef75dea354df7e33335635d2f1f11048e9b10f9e3e07e98a36c6a7c" }, "downloads": -1, "filename": "z3c.mountpoint-0.1.tar.gz", "has_sig": false, "md5_digest": "24136a417a24c294049fdb3df47f529d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8803, "upload_time": "2010-08-03T08:29:46", "url": "https://files.pythonhosted.org/packages/34/5a/980992767d10c9618ecb451a52c0bc8ac8370e88302fa7cef988727d464d/z3c.mountpoint-0.1.tar.gz" } ] }