zope.location-4.0.3/0000775000175000017500000000000012312364651014213 5ustar tseavertseaverzope.location-4.0.3/setup.cfg0000664000175000017500000000040612312364651016034 0ustar tseavertseaver[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 [nosetests] cover-package = zope.location nocapture = 1 cover-erase = 1 with-doctest = 0 where = src [aliases] dev = develop easy_install zope.location[testing] docs = easy_install zope.location[docs] zope.location-4.0.3/buildout.cfg0000664000175000017500000000060112167130545016521 0ustar tseavertseaver[buildout] develop = . parts = test coverage-test coverage-report [test] recipe = zc.recipe.testrunner eggs = zope.location [zcml] [coverage-test] recipe = zc.recipe.testrunner eggs = zope.location defaults = ['--coverage', '../../coverage'] [coverage-report] recipe = zc.recipe.egg eggs = z3c.coverage scripts = coverage=coverage-report arguments = ('coverage', 'coverage/report') zope.location-4.0.3/PKG-INFO0000664000175000017500000002130312312364651015307 0ustar tseavertseaverMetadata-Version: 1.0 Name: zope.location Version: 4.0.3 Summary: Zope Location Home-page: http://pypi.python.org/pypi/zope.location/ Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Description: Zope Location ============= Overview ======== In Zope3, location are special objects that has a structural location. ======= CHANGES ======= 4.0.3 (2014-03-19) ------------------ - Added Python 3.4 support. - Updated ``boostrap.py`` to version 2.2. 4.0.2 (2013-03-11) ------------------ - Changed the behavior of ``LocationProxy``'s ``__setattr__()`` to correctly behave when dealing with the pure Python version of the ``ProxyBase`` class. Also added a test suite that fully tests the pure Python proxy version of the ``LocationProxy`` class. 4.0.1 (2013-02-19) ------------------ - Added Python 3.3 support. 4.0.0 (2012-06-07) ------------------ - Removed backward-compatibility imports: - ``zope.copy.clone`` (aliased as ``zope.location.pickling.locationCopy``) - ``zope.copy.CopyPersistent`` (aliased as ``zope.location.pickling.CopyPersistent``). - ``zope.site.interfaces.IPossibleSite`` (aliased as ``zope.location.interfaces.IPossibleSite``). - Added Python 3.2 support. - Made ``zope.component`` dependency optional. Use the ``component`` extra to force its installation (or just require it directly). If ``zope.component`` is not present, this package defines the ``ISite`` interface itself, and omits adapter registrations from its ZCML. - Added support for PyPy. - Added support for continuous integration using ``tox`` and ``jenkins``. - 100% unit test coverage. - Added Sphinx documentation: moved doctest examples to API reference. - Added 'setup.py docs' alias (installs ``Sphinx`` and dependencies). - Added 'setup.py dev' alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Replaced deprecated ``zope.component.adapts`` usage with equivalent ``zope.component.adapter`` decorator. - Replaced deprecated ``zope.interface.implements`` usage with equivalent ``zope.interface.implementer`` decorator. - Dropped support for Python 2.4 and 2.5. 3.9.1 (2011-08-22) ------------------ - Added zcml extra as well as a test for configure.zcml. 3.9.0 (2009-12-29) ------------------ - Moved LocationCopyHook related tests to zope.copy and remove a test dependency on that package. 3.8.2 (2009-12-23) ------------------ - Fixed a typo in the configure.zcml. 3.8.1 (2009-12-23) ------------------ - Removed dependency on zope.copy: the LocationCopyHook adapter is registered only if zope.copy is available. - Use the standard Python doctest module instead of zope.testing.doctest, which has been deprecated. 3.8.0 (2009-12-22) ------------------ - Adjusted to testing output caused by new zope.schema. 3.7.1 (2009-11-18) ------------------ - Moved the IPossibleSite and ISite interfaces to zope.component as they are dealing with zope.component's concept of a site, but not with location. 3.7.0 (2009-09-29) ------------------ - Added getParent() to ILocationInfo and moved the actual implementation here from zope.traversal.api, analogous to getParents(). - Actually removed deprecated PathPersistent class from zope.location.pickling. - Moved ITraverser back to zope.traversing where it belongs conceptually. The interface had been moved to zope.location to invert the package interdependency but is no longer used here. 3.6.0 (2009-08-27) ------------------ - New feature release: deprecated locationCopy, CopyPersistent and PathPersistent from zope.location.pickling. These changes were already part of the 3.5.3 release, which was erroneously numbered as a bugfix relese. - Removed dependency on zope.deferredimport, directly import deprecated modules without using it. 3.5.5 (2009-08-15) ------------------ - Add zope.deferredimport as a dependency as it's used directly by zope.location.pickling. 3.5.4 (2009-05-17) ------------------ - Add ``IContained`` interface to ``zope.location.interfaces`` module. This interface was moved from ``zope.container`` (after ``zope.container`` 3.8.2); consumers of ``IContained`` may now depend on zope.location rather than zope.container to reduce dependency cycles. 3.5.3 (2009-02-09) ------------------ - Use new zope.copy package for implementing location copying. Thus there's changes in the ``zope.locaton.pickling`` module: * The ``locationCopy`` and ``CopyPersistent`` was removed in prefer to their equivalents in zope.copy. Deprecated backward-compatibility imports provided. * The module now provides a ``zope.copy.interfaces.ICopyHook`` adapter for ``ILocation`` objects that replaces the old CopyPersistent functionality of checking for the need to clone objects based on their location. 3.5.2 (2009-02-04) ------------------ - Split RootPhysicallyLocatable adapter back from LocationPhysicallyLocatable, because the IRoot object may not always provide ILocation and the code for the root object is also simplier. It's basically a copy of the RootPhysicallyLocatable adapter from zope.traversing version 3.5.0 and below with ``getParents`` method added (returns an empty list). 3.5.1 (2009-02-02) ------------------ - Improve test coverage. - The new ``getParents`` method was extracted from ``zope.traversing`` and added to ILocationInfo interface in the previous release. Custom ILocationInfo implementations should make sure they have this method as well. That method is already used in ``zope.traversing.api.getParents`` function. - Make ``getName`` of LocationPhysicallyLocatable always return empty string for the IRoot object, like RootPhysicallyLocatable from ``zope.traversing`` did. So, now LocationPhysicallyLocatable is fully compatible with RootPhysicallyLocatable, making the latter one obsolete. - Change package mailing list address to zope-dev at zope.org instead of retired zope3-dev at zope.org. 3.5.0 (2009-01-31) ------------------ - Reverse the dependency between zope.location and zope.traversing. This also causes the dependency to various other packages go away. 3.4.0 (2007-10-02) ------------------ - Initial release independent of the main Zope tree. Keywords: zope location structural Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Topic :: Internet :: WWW/HTTP Classifier: Framework :: Zope3 zope.location-4.0.3/tox.ini0000664000175000017500000000256712312122014015521 0ustar tseavertseaver[tox] envlist = # Jython support pending 2.7 support, due 2012-07-15 or so. See: # http://fwierzbicki.blogspot.com/2012/03/adconion-to-fund-jython-27.html # py26,py27,py32,jython,pypy,coverage py26,py27,py32,py33,py34,pypy,coverage,docs [testenv] commands = python setup.py test -q deps = zope.configuration zope.copy zope.interface zope.proxy zope.schema [testenv:jython] commands = jython setup.py test -q deps = zope.configuration zope.copy zope.interface zope.proxy zope.schema [testenv:coverage] basepython = python2.6 commands = # The installed version messes up nose's test discovery / coverage reporting # So, we uninstall that from the environment, and then install the editable # version, before running nosetests. pip uninstall -y zope.location pip install -e . nosetests --with-xunit --with-xcoverage deps = zope.configuration zope.copy zope.interface zope.proxy zope.schema zope.component nose coverage nosexcover [testenv:docs] basepython = python2.6 commands = sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest deps = zope.configuration zope.copy zope.interface zope.proxy zope.schema zope.component Sphinx repoze.sphinx.autointerface zope.location-4.0.3/.gitignore0000664000175000017500000000017612073045170016203 0ustar tseavertseaver*.pyc __pycache__ *.egg-info .installed.cfg bin develop-eggs eggs parts docs/_build .tox .coverage nosetests.xml coverage.xml zope.location-4.0.3/setup.py0000664000175000017500000000626312312364567015742 0ustar tseavertseaver############################################################################## # # Copyright (c) 2006 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## # This package is developed by the Zope Toolkit project, documented here: # http://docs.zope.org/zopetoolkit # When developing and releasing this package, please follow the documented # Zope Toolkit policies as described by this documentation. ############################################################################## """Setup for zope.location package """ import os from setuptools import setup, find_packages def read(*rnames): text = open(os.path.join(os.path.dirname(__file__), *rnames)).read() return text setup(name='zope.location', version='4.0.3', author='Zope Corporation and Contributors', author_email='zope-dev@zope.org', description='Zope Location', long_description=( read('README.rst') + '\n\n' + read('CHANGES.rst') ), license='ZPL 2.1', keywords=('zope location structural'), classifiers = [ 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: Zope Public License', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Natural Language :: English', 'Operating System :: OS Independent', 'Topic :: Internet :: WWW/HTTP', 'Framework :: Zope3'], url='http://pypi.python.org/pypi/zope.location/', packages=find_packages('src'), package_dir = {'': 'src'}, namespace_packages=['zope',], install_requires=['setuptools', 'zope.interface>=4.0.2', 'zope.schema>=4.2.2', 'zope.proxy>=4.0.1', ], extras_require={ 'zcml': ['zope.configuration'], 'component': ['zope.component>=4.0.1'], 'testing': [ 'nose', 'coverage', 'zope.configuration>=4.0', 'zope.copy>=4.0', ], 'docs': ['Sphinx', 'repoze.sphinx.autointerface'], }, test_suite='zope.location.tests', include_package_data = True, zip_safe = False, ) zope.location-4.0.3/bootstrap.py0000664000175000017500000001306612167130605016606 0ustar tseavertseaver############################################################################## # # Copyright (c) 2006 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Bootstrap a buildout-based project Simply run this script in a directory containing a buildout.cfg. The script accepts buildout command-line options, so you can use the -c option to specify an alternate configuration file. """ import os import shutil import sys import tempfile from optparse import OptionParser tmpeggs = tempfile.mkdtemp() usage = '''\ [DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options] Bootstraps a buildout-based project. Simply run this script in a directory containing a buildout.cfg, using the Python that you want bin/buildout to use. Note that by using --find-links to point to local resources, you can keep this script from going over the network. ''' parser = OptionParser(usage=usage) parser.add_option("-v", "--version", help="use a specific zc.buildout version") parser.add_option("-t", "--accept-buildout-test-releases", dest='accept_buildout_test_releases', action="store_true", default=False, help=("Normally, if you do not specify a --version, the " "bootstrap script and buildout gets the newest " "*final* versions of zc.buildout and its recipes and " "extensions for you. If you use this flag, " "bootstrap and buildout will get the newest releases " "even if they are alphas or betas.")) parser.add_option("-c", "--config-file", help=("Specify the path to the buildout configuration " "file to be used.")) parser.add_option("-f", "--find-links", help=("Specify a URL to search for buildout releases")) options, args = parser.parse_args() ###################################################################### # load/install setuptools to_reload = False try: import pkg_resources import setuptools except ImportError: ez = {} try: from urllib.request import urlopen except ImportError: from urllib2 import urlopen # XXX use a more permanent ez_setup.py URL when available. exec(urlopen('https://bitbucket.org/pypa/setuptools/raw/0.7.2/ez_setup.py' ).read(), ez) setup_args = dict(to_dir=tmpeggs, download_delay=0) ez['use_setuptools'](**setup_args) if to_reload: reload(pkg_resources) import pkg_resources # This does not (always?) update the default working set. We will # do it. for path in sys.path: if path not in pkg_resources.working_set.entries: pkg_resources.working_set.add_entry(path) ###################################################################### # Install buildout ws = pkg_resources.working_set cmd = [sys.executable, '-c', 'from setuptools.command.easy_install import main; main()', '-mZqNxd', tmpeggs] find_links = os.environ.get( 'bootstrap-testing-find-links', options.find_links or ('http://downloads.buildout.org/' if options.accept_buildout_test_releases else None) ) if find_links: cmd.extend(['-f', find_links]) setuptools_path = ws.find( pkg_resources.Requirement.parse('setuptools')).location requirement = 'zc.buildout' version = options.version if version is None and not options.accept_buildout_test_releases: # Figure out the most recent final version of zc.buildout. import setuptools.package_index _final_parts = '*final-', '*final' def _final_version(parsed_version): for part in parsed_version: if (part[:1] == '*') and (part not in _final_parts): return False return True index = setuptools.package_index.PackageIndex( search_path=[setuptools_path]) if find_links: index.add_find_links((find_links,)) req = pkg_resources.Requirement.parse(requirement) if index.obtain(req) is not None: best = [] bestv = None for dist in index[req.project_name]: distv = dist.parsed_version if _final_version(distv): if bestv is None or distv > bestv: best = [dist] bestv = distv elif distv == bestv: best.append(dist) if best: best.sort() version = best[-1].version if version: requirement = '=='.join((requirement, version)) cmd.append(requirement) import subprocess if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0: raise Exception( "Failed to execute command:\n%s", repr(cmd)[1:-1]) ###################################################################### # Import and run buildout ws.add_entry(tmpeggs) ws.require(requirement) import zc.buildout.buildout if not [a for a in args if '=' not in a]: args.append('bootstrap') # if -c was provided, we push it back into args for buildout' main function if options.config_file is not None: args[0:0] = ['-c', options.config_file] zc.buildout.buildout.main(args) shutil.rmtree(tmpeggs) zope.location-4.0.3/.travis.yml0000664000175000017500000000027512167130545016331 0ustar tseavertseaverlanguage: python python: - 2.6 - 2.7 - 3.2 - 3.3 - pypy install: - pip install . --use-mirrors script: - python setup.py test -q notifications: email: false zope.location-4.0.3/src/0000775000175000017500000000000012312364651015002 5ustar tseavertseaverzope.location-4.0.3/src/zope.location.egg-info/0000775000175000017500000000000012312364651021260 5ustar tseavertseaverzope.location-4.0.3/src/zope.location.egg-info/top_level.txt0000664000175000017500000000000512312364651024005 0ustar tseavertseaverzope zope.location-4.0.3/src/zope.location.egg-info/SOURCES.txt0000664000175000017500000000462212312364651023150 0ustar tseavertseaver.gitignore .travis.yml CHANGES.rst COPYRIGHT.txt LICENSE.txt MANIFEST.in README.rst bootstrap.py buildout.cfg setup.cfg setup.py tox.ini docs/Makefile docs/api.rst docs/conf.py docs/index.rst docs/make.bat docs/narr.rst docs/_build/doctest/output.txt docs/_build/doctrees/api.doctree docs/_build/doctrees/environment.pickle docs/_build/doctrees/index.doctree docs/_build/doctrees/narr.doctree docs/_build/html/.buildinfo docs/_build/html/api.html docs/_build/html/genindex.html docs/_build/html/index.html docs/_build/html/narr.html docs/_build/html/objects.inv docs/_build/html/py-modindex.html docs/_build/html/search.html docs/_build/html/searchindex.js docs/_build/html/_modules/index.html docs/_build/html/_modules/zope/location/interfaces.html docs/_build/html/_modules/zope/location/location.html docs/_build/html/_modules/zope/location/traversing.html docs/_build/html/_sources/api.txt docs/_build/html/_sources/index.txt docs/_build/html/_sources/narr.txt docs/_build/html/_static/ajax-loader.gif docs/_build/html/_static/basic.css docs/_build/html/_static/comment-bright.png docs/_build/html/_static/comment-close.png docs/_build/html/_static/comment.png docs/_build/html/_static/default.css docs/_build/html/_static/doctools.js docs/_build/html/_static/down-pressed.png docs/_build/html/_static/down.png docs/_build/html/_static/file.png docs/_build/html/_static/jquery.js docs/_build/html/_static/minus.png docs/_build/html/_static/plus.png docs/_build/html/_static/pygments.css docs/_build/html/_static/searchtools.js docs/_build/html/_static/sidebar.js docs/_build/html/_static/underscore.js docs/_build/html/_static/up-pressed.png docs/_build/html/_static/up.png docs/_build/html/_static/websupport.js src/zope/__init__.py src/zope.location.egg-info/PKG-INFO src/zope.location.egg-info/SOURCES.txt src/zope.location.egg-info/dependency_links.txt src/zope.location.egg-info/namespace_packages.txt src/zope.location.egg-info/not-zip-safe src/zope.location.egg-info/requires.txt src/zope.location.egg-info/top_level.txt src/zope/location/__init__.py src/zope/location/_compat.py src/zope/location/configure.zcml src/zope/location/interfaces.py src/zope/location/location.py src/zope/location/pickling.py src/zope/location/traversing.py src/zope/location/tests/__init__.py src/zope/location/tests/test_configure.py src/zope/location/tests/test_location.py src/zope/location/tests/test_pickling.py src/zope/location/tests/test_traversing.pyzope.location-4.0.3/src/zope.location.egg-info/PKG-INFO0000664000175000017500000002130312312364651022354 0ustar tseavertseaverMetadata-Version: 1.0 Name: zope.location Version: 4.0.3 Summary: Zope Location Home-page: http://pypi.python.org/pypi/zope.location/ Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Description: Zope Location ============= Overview ======== In Zope3, location are special objects that has a structural location. ======= CHANGES ======= 4.0.3 (2014-03-19) ------------------ - Added Python 3.4 support. - Updated ``boostrap.py`` to version 2.2. 4.0.2 (2013-03-11) ------------------ - Changed the behavior of ``LocationProxy``'s ``__setattr__()`` to correctly behave when dealing with the pure Python version of the ``ProxyBase`` class. Also added a test suite that fully tests the pure Python proxy version of the ``LocationProxy`` class. 4.0.1 (2013-02-19) ------------------ - Added Python 3.3 support. 4.0.0 (2012-06-07) ------------------ - Removed backward-compatibility imports: - ``zope.copy.clone`` (aliased as ``zope.location.pickling.locationCopy``) - ``zope.copy.CopyPersistent`` (aliased as ``zope.location.pickling.CopyPersistent``). - ``zope.site.interfaces.IPossibleSite`` (aliased as ``zope.location.interfaces.IPossibleSite``). - Added Python 3.2 support. - Made ``zope.component`` dependency optional. Use the ``component`` extra to force its installation (or just require it directly). If ``zope.component`` is not present, this package defines the ``ISite`` interface itself, and omits adapter registrations from its ZCML. - Added support for PyPy. - Added support for continuous integration using ``tox`` and ``jenkins``. - 100% unit test coverage. - Added Sphinx documentation: moved doctest examples to API reference. - Added 'setup.py docs' alias (installs ``Sphinx`` and dependencies). - Added 'setup.py dev' alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Replaced deprecated ``zope.component.adapts`` usage with equivalent ``zope.component.adapter`` decorator. - Replaced deprecated ``zope.interface.implements`` usage with equivalent ``zope.interface.implementer`` decorator. - Dropped support for Python 2.4 and 2.5. 3.9.1 (2011-08-22) ------------------ - Added zcml extra as well as a test for configure.zcml. 3.9.0 (2009-12-29) ------------------ - Moved LocationCopyHook related tests to zope.copy and remove a test dependency on that package. 3.8.2 (2009-12-23) ------------------ - Fixed a typo in the configure.zcml. 3.8.1 (2009-12-23) ------------------ - Removed dependency on zope.copy: the LocationCopyHook adapter is registered only if zope.copy is available. - Use the standard Python doctest module instead of zope.testing.doctest, which has been deprecated. 3.8.0 (2009-12-22) ------------------ - Adjusted to testing output caused by new zope.schema. 3.7.1 (2009-11-18) ------------------ - Moved the IPossibleSite and ISite interfaces to zope.component as they are dealing with zope.component's concept of a site, but not with location. 3.7.0 (2009-09-29) ------------------ - Added getParent() to ILocationInfo and moved the actual implementation here from zope.traversal.api, analogous to getParents(). - Actually removed deprecated PathPersistent class from zope.location.pickling. - Moved ITraverser back to zope.traversing where it belongs conceptually. The interface had been moved to zope.location to invert the package interdependency but is no longer used here. 3.6.0 (2009-08-27) ------------------ - New feature release: deprecated locationCopy, CopyPersistent and PathPersistent from zope.location.pickling. These changes were already part of the 3.5.3 release, which was erroneously numbered as a bugfix relese. - Removed dependency on zope.deferredimport, directly import deprecated modules without using it. 3.5.5 (2009-08-15) ------------------ - Add zope.deferredimport as a dependency as it's used directly by zope.location.pickling. 3.5.4 (2009-05-17) ------------------ - Add ``IContained`` interface to ``zope.location.interfaces`` module. This interface was moved from ``zope.container`` (after ``zope.container`` 3.8.2); consumers of ``IContained`` may now depend on zope.location rather than zope.container to reduce dependency cycles. 3.5.3 (2009-02-09) ------------------ - Use new zope.copy package for implementing location copying. Thus there's changes in the ``zope.locaton.pickling`` module: * The ``locationCopy`` and ``CopyPersistent`` was removed in prefer to their equivalents in zope.copy. Deprecated backward-compatibility imports provided. * The module now provides a ``zope.copy.interfaces.ICopyHook`` adapter for ``ILocation`` objects that replaces the old CopyPersistent functionality of checking for the need to clone objects based on their location. 3.5.2 (2009-02-04) ------------------ - Split RootPhysicallyLocatable adapter back from LocationPhysicallyLocatable, because the IRoot object may not always provide ILocation and the code for the root object is also simplier. It's basically a copy of the RootPhysicallyLocatable adapter from zope.traversing version 3.5.0 and below with ``getParents`` method added (returns an empty list). 3.5.1 (2009-02-02) ------------------ - Improve test coverage. - The new ``getParents`` method was extracted from ``zope.traversing`` and added to ILocationInfo interface in the previous release. Custom ILocationInfo implementations should make sure they have this method as well. That method is already used in ``zope.traversing.api.getParents`` function. - Make ``getName`` of LocationPhysicallyLocatable always return empty string for the IRoot object, like RootPhysicallyLocatable from ``zope.traversing`` did. So, now LocationPhysicallyLocatable is fully compatible with RootPhysicallyLocatable, making the latter one obsolete. - Change package mailing list address to zope-dev at zope.org instead of retired zope3-dev at zope.org. 3.5.0 (2009-01-31) ------------------ - Reverse the dependency between zope.location and zope.traversing. This also causes the dependency to various other packages go away. 3.4.0 (2007-10-02) ------------------ - Initial release independent of the main Zope tree. Keywords: zope location structural Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Topic :: Internet :: WWW/HTTP Classifier: Framework :: Zope3 zope.location-4.0.3/src/zope.location.egg-info/dependency_links.txt0000664000175000017500000000000112312364651025326 0ustar tseavertseaver zope.location-4.0.3/src/zope.location.egg-info/not-zip-safe0000664000175000017500000000000112073045115023501 0ustar tseavertseaver zope.location-4.0.3/src/zope.location.egg-info/namespace_packages.txt0000664000175000017500000000000512312364651025606 0ustar tseavertseaverzope zope.location-4.0.3/src/zope.location.egg-info/requires.txt0000664000175000017500000000035612312364651023664 0ustar tseavertseaversetuptools zope.interface>=4.0.2 zope.schema>=4.2.2 zope.proxy>=4.0.1 [docs] Sphinx repoze.sphinx.autointerface [testing] nose coverage zope.configuration>=4.0 zope.copy>=4.0 [component] zope.component>=4.0.1 [zcml] zope.configurationzope.location-4.0.3/src/zope/0000775000175000017500000000000012312364651015757 5ustar tseavertseaverzope.location-4.0.3/src/zope/location/0000775000175000017500000000000012312364651017567 5ustar tseavertseaverzope.location-4.0.3/src/zope/location/_compat.py0000664000175000017500000000146712073042223021563 0ustar tseavertseaver############################################################################## # # Copyright (c) 2003-2009 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## import sys PY3 = sys.version_info[0] >= 3 if PY3: #pragma NO COVER def u(s): return s else: #pragma NO COVER def u(s): return unicode(s, "unicode_escape") zope.location-4.0.3/src/zope/location/__init__.py0000664000175000017500000000154412073042223021674 0ustar tseavertseaver############################################################################## # # Copyright (c) 2003-2009 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Locations """ __docformat__ = 'restructuredtext' from zope.location.interfaces import ILocation from zope.location.location import Location, locate, LocationIterator from zope.location.location import inside, LocationProxy zope.location-4.0.3/src/zope/location/interfaces.py0000664000175000017500000000773412073042223022267 0ustar tseavertseaver############################################################################## # # Copyright (c) 2003-2009 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Location framework interfaces """ __docformat__ = 'restructuredtext' from zope.interface import Interface from zope.interface import Attribute from zope.schema import TextLine from zope.location._compat import u class ILocation(Interface): """Objects that can be located in a hierachy. Given a parent and a name an object can be located within that parent. The locatable object's `__name__` and `__parent__` attributes store this information. Located objects form a hierarchy that can be used to build file-system-like structures. For example in Zope `ILocation` is used to build URLs and to support security machinery. To retrieve an object from its parent using its name, the `ISublocation` interface provides the `sublocations` method to iterate over all objects located within the parent. The object searched for can be found by reading each sublocation's __name__ attribute. """ __parent__ = Attribute("The parent in the location hierarchy.") __name__ = TextLine( title=u("The name within the parent"), description=u("The object can be looked up from the parent's " "sublocations using this name."), required=False, default=None) # The IContained interface was moved from zope.container to here in # zope.container 3.8.2 to break dependency cycles. It is not actually # used within this package, but is depended upon by external # consumers. class IContained(ILocation): """Objects contained in containers.""" class ILocationInfo(Interface): """Provides supplemental information for located objects. Requires that the object has been given a location in a hierarchy. """ def getRoot(): """Return the root object of the hierarchy.""" def getPath(): """Return the physical path to the object as a string. Uses '/' as the path segment separator. """ def getParent(): """Returns the container the object was traversed via. Returns None if the object is a containment root. Raises TypeError if the object doesn't have enough context to get the parent. """ def getParents(): """Returns a list starting with the object's parent followed by each of its parents. Raises a TypeError if the object is not connected to a containment root. """ def getName(): """Return the last segment of the physical path.""" def getNearestSite(): """Return the site the object is contained in If the object is a site, the object itself is returned. """ class ISublocations(Interface): """Provide access to sublocations of an object. All objects with the same parent object are called the ``sublocations`` of that parent. """ def sublocations(): """Return an iterable of the object's sublocations.""" class IRoot(Interface): """Marker interface to designate root objects within a location hierarchy. """ class LocationError(KeyError, LookupError): """There is no object for a given location.""" # Soft dependency on zope.component. # # Also, these interfaces used to be defined here directly, so this provides # backwardc-comppatibiltiy try: from zope.component.interfaces import ISite except ImportError: #pragma NO COVER class ISite(Interface): pass zope.location-4.0.3/src/zope/location/pickling.py0000664000175000017500000000261312073042223021733 0ustar tseavertseaver############################################################################## # # Copyright (c) 2003-2009 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Location copying/pickling support """ __docformat__ = 'restructuredtext' from zope.interface import implementer from zope.location.location import inside try: from zope.copy.interfaces import ICopyHook, ResumeCopy except ImportError: #pragma NO COVER raise NotImplementedError("zope.location.pickling is not supported " "because zope.copy is not available") @implementer(ICopyHook) class LocationCopyHook(object): """Copy hook to preserve copying referenced objects that are not located inside object that's being copied. """ def __init__(self, context): self.context = context def __call__(self, toplevel, register): if not inside(self.context, toplevel): return self.context raise ResumeCopy zope.location-4.0.3/src/zope/location/tests/0000775000175000017500000000000012312364651020731 5ustar tseavertseaverzope.location-4.0.3/src/zope/location/tests/test_traversing.py0000664000175000017500000002412212073042223024517 0ustar tseavertseaver############################################################################## # # Copyright (c) 2012 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## import unittest class ConformsToILocationInfo(object): def test_class_conforms_to_ILocationInfo(self): from zope.interface.verify import verifyClass from zope.location.interfaces import ILocationInfo verifyClass(ILocationInfo, self._getTargetClass()) def test_instance_conforms_to_ILocationInfo(self): from zope.interface.verify import verifyObject from zope.location.interfaces import ILocationInfo verifyObject(ILocationInfo, self._makeOne()) class LocationPhysicallyLocatableTests( unittest.TestCase, ConformsToILocationInfo): def _getTargetClass(self): from zope.location.traversing import LocationPhysicallyLocatable return LocationPhysicallyLocatable def _makeOne(self, obj=None): if obj is None: obj = object() return self._getTargetClass()(obj) def test_getRoot_not_location_aware(self): proxy = self._makeOne(object()) self.assertRaises(AttributeError, proxy.getRoot) def test_getRoot_location_but_no_IRoot(self): class Dummy(object): __parent__ = None proxy = self._makeOne(Dummy()) self.assertRaises(TypeError, proxy.getRoot) def test_getRoot_wo_cycle(self): from zope.interface import directlyProvides from zope.location.interfaces import IRoot class Dummy(object): __parent__ = None one = Dummy() directlyProvides(one, IRoot) two = Dummy() two.__parent__ = one three = Dummy() three.__parent__ = two proxy = self._makeOne(three) self.assertTrue(proxy.getRoot() is one) def test_getRoot_w_cycle(self): class Dummy(object): __parent__ = None one = Dummy() two = Dummy() two.__parent__ = one three = Dummy() three.__parent__ = two one.__parent__ = three proxy = self._makeOne(two) self.assertRaises(TypeError, proxy.getRoot) def test_getPath_not_location_aware(self): proxy = self._makeOne(object()) self.assertRaises(AttributeError, proxy.getPath) def test_getPath_location_but_no_IRoot(self): class Dummy(object): __parent__ = __name__ = None proxy = self._makeOne(Dummy()) self.assertRaises(TypeError, proxy.getPath) def test_getPath_at_root(self): from zope.interface import directlyProvides from zope.location.interfaces import IRoot class Dummy(object): __parent__ = __name__ = None one = Dummy() directlyProvides(one, IRoot) proxy = self._makeOne(one) self.assertEqual(proxy.getPath(), '/') def test_getPath_wo_cycle(self): from zope.interface import directlyProvides from zope.location.interfaces import IRoot class Dummy(object): __parent__ = __name__ = None one = Dummy() directlyProvides(one, IRoot) two = Dummy() two.__parent__ = one two.__name__ = 'two' three = Dummy() three.__parent__ = two three.__name__ = 'three' proxy = self._makeOne(three) self.assertEqual(proxy.getPath(), '/two/three') def test_getPath_w_cycle(self): class Dummy(object): __parent__ = __name__ = None one = Dummy() two = Dummy() two.__parent__ = one two.__name__ = 'two' three = Dummy() three.__parent__ = two three.__name__ = 'three' one.__parent__ = three proxy = self._makeOne(two) self.assertRaises(TypeError, proxy.getPath) def test_getParent_not_location_aware(self): proxy = self._makeOne(object()) self.assertRaises(TypeError, proxy.getParent) def test_getParent_location_but_no_IRoot(self): class Dummy(object): __parent__ = __name__ = None proxy = self._makeOne(Dummy()) self.assertRaises(TypeError, proxy.getParent) def test_getParent_at_root(self): from zope.interface import directlyProvides from zope.location.interfaces import IRoot class Dummy(object): __parent__ = __name__ = None one = Dummy() directlyProvides(one, IRoot) proxy = self._makeOne(one) self.assertRaises(TypeError, proxy.getParent) def test_getParent_wo_cycle(self): from zope.interface import directlyProvides from zope.location.interfaces import IRoot class Dummy(object): __parent__ = __name__ = None one = Dummy() directlyProvides(one, IRoot) two = Dummy() two.__parent__ = one two.__name__ = 'two' three = Dummy() three.__parent__ = two three.__name__ = 'three' proxy = self._makeOne(three) self.assertTrue(proxy.getParent() is two) def test_getParents_not_location_aware(self): proxy = self._makeOne(object()) self.assertRaises(TypeError, proxy.getParents) def test_getParents_location_but_no_IRoot(self): class Dummy(object): __parent__ = __name__ = None proxy = self._makeOne(Dummy()) self.assertRaises(TypeError, proxy.getParents) def test_getParents_at_root(self): from zope.interface import directlyProvides from zope.location.interfaces import IRoot class Dummy(object): __parent__ = __name__ = None one = Dummy() directlyProvides(one, IRoot) proxy = self._makeOne(one) self.assertRaises(TypeError, proxy.getParents) def test_getParents_wo_cycle(self): from zope.interface import directlyProvides from zope.location.interfaces import IRoot class Dummy(object): __parent__ = __name__ = None one = Dummy() directlyProvides(one, IRoot) two = Dummy() two.__parent__ = one two.__name__ = 'two' three = Dummy() three.__parent__ = two three.__name__ = 'three' proxy = self._makeOne(three) self.assertEqual(proxy.getParents(), [two, one]) def test_getName_not_location_aware(self): proxy = self._makeOne(object()) self.assertRaises(AttributeError, proxy.getName) def test_getName_location(self): class Dummy(object): __name__ = None proxy = self._makeOne(Dummy()) self.assertEqual(proxy.getName(), None) def test_getName_location_w_name(self): class Dummy(object): __name__ = 'name' proxy = self._makeOne(Dummy()) self.assertEqual(proxy.getName(), 'name') def test_getNearestSite_context_is_site(self): from zope.location.interfaces import ISite # zope.component, if present from zope.interface import directlyProvides class Dummy(object): pass context = Dummy() directlyProvides(context, ISite) proxy = self._makeOne(context) self.assertTrue(proxy.getNearestSite() is context) def test_getNearestSite_ancestor_is_site(self): from zope.location.interfaces import ISite # zope.component, if present from zope.interface import directlyProvides from zope.location.interfaces import IRoot class Dummy(object): pass one = Dummy() directlyProvides(one, (ISite, IRoot)) two = Dummy() two.__parent__ = one two.__name__ = 'two' three = Dummy() three.__parent__ = two three.__name__ = 'three' proxy = self._makeOne(three) self.assertTrue(proxy.getNearestSite() is one) def test_getNearestSite_no_site(self): from zope.interface import directlyProvides from zope.location.interfaces import IRoot class Dummy(object): __parent__ = __name__ = None one = Dummy() directlyProvides(one, IRoot) two = Dummy() two.__parent__ = one two.__name__ = 'two' three = Dummy() three.__parent__ = two three.__name__ = 'three' proxy = self._makeOne(three) self.assertTrue(proxy.getNearestSite() is one) class RootPhysicallyLocatableTests( unittest.TestCase, ConformsToILocationInfo): def _getTargetClass(self): from zope.location.traversing import RootPhysicallyLocatable return RootPhysicallyLocatable def _makeOne(self, obj=None): if obj is None: obj = object() return self._getTargetClass()(obj) def test_getRoot(self): context = object() proxy = self._makeOne(context) self.assertTrue(proxy.getRoot() is context) def test_getPath(self): context = object() proxy = self._makeOne(context) self.assertEqual(proxy.getPath(), '/') def test_getParent(self): context = object() proxy = self._makeOne(context) self.assertEqual(proxy.getParent(), None) def test_getParents(self): context = object() proxy = self._makeOne(context) self.assertEqual(proxy.getParents(), []) def test_getName(self): context = object() proxy = self._makeOne(context) self.assertEqual(proxy.getName(), '') def test_getNearestSite(self): context = object() proxy = self._makeOne(context) self.assertTrue(proxy.getNearestSite() is context) def test_suite(): return unittest.TestSuite(( unittest.makeSuite(LocationPhysicallyLocatableTests), unittest.makeSuite(RootPhysicallyLocatableTests), )) zope.location-4.0.3/src/zope/location/tests/__init__.py0000664000175000017500000000001112073042223023022 0ustar tseavertseaver#package zope.location-4.0.3/src/zope/location/tests/test_location.py0000664000175000017500000003413612167130545024162 0ustar tseavertseaver############################################################################## # # Copyright (c) 2012 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## import unittest class ConformsToILocation(object): def test_class_conforms_to_ILocation(self): from zope.interface.verify import verifyClass from zope.location.interfaces import ILocation verifyClass(ILocation, self._getTargetClass()) def test_instance_conforms_to_ILocation(self): from zope.interface.verify import verifyObject from zope.location.interfaces import ILocation verifyObject(ILocation, self._makeOne()) class LocationTests(unittest.TestCase, ConformsToILocation): def _getTargetClass(self): from zope.location.location import Location return Location def _makeOne(self): return self._getTargetClass()() def test_ctor(self): loc = self._makeOne() self.assertEqual(loc.__parent__, None) self.assertEqual(loc.__name__, None) class Test_locate(unittest.TestCase): def _callFUT(self, obj, *args, **kw): from zope.location.location import locate return locate(obj, *args, **kw) def test_wo_name(self): class Dummy(object): pass parent = Dummy() dummy = Dummy() self._callFUT(dummy, parent) self.assertTrue(dummy.__parent__ is parent) self.assertEqual(dummy.__name__, None) def test_w_name(self): class Dummy(object): pass parent = Dummy() dummy = Dummy() self._callFUT(dummy, parent, 'name') self.assertTrue(dummy.__parent__ is parent) self.assertEqual(dummy.__name__, 'name') class Test_located(unittest.TestCase): def _callFUT(self, obj, *args, **kw): from zope.location.location import located return located(obj, *args, **kw) def test_wo_name_obj_implements_ILocation(self): from zope.interface import implementer from zope.location.interfaces import ILocation @implementer(ILocation) class Dummy(object): __parent__ = None __name__ = object() parent = Dummy() dummy = Dummy() self._callFUT(dummy, parent) self.assertTrue(dummy.__parent__ is parent) self.assertEqual(dummy.__name__, None) def test_w_name_adaptable_to_ILocation(self): from zope.interface.interface import adapter_hooks from zope.location.interfaces import ILocation _hooked = [] def _hook(iface, obj): _hooked.append((iface, obj)) return obj class Dummy(object): pass parent = Dummy() dummy = Dummy() before = adapter_hooks[:] adapter_hooks.insert(0, _hook) try: self._callFUT(dummy, parent, 'name') finally: adapter_hooks[:] = before self.assertTrue(dummy.__parent__ is parent) self.assertEqual(dummy.__name__, 'name') self.assertEqual(len(_hooked), 1) self.assertEqual(_hooked[0], (ILocation, dummy)) def test_wo_name_not_adaptable_to_ILocation(self): class Dummy(object): __parent__ = None __name__ = 'before' parent = Dummy() dummy = Dummy() self.assertRaises(TypeError, self._callFUT, dummy, parent, 'name') self.assertEqual(dummy.__parent__, None) self.assertEqual(dummy.__name__, 'before') class Test_LocationIterator(unittest.TestCase): def _callFUT(self, obj): from zope.location.location import LocationIterator return LocationIterator(obj) def test_w_None(self): self.assertEqual(list(self._callFUT(None)), []) def test_w_non_location_object(self): island = object() self.assertEqual(list(self._callFUT(island)), [island]) def test_w_isolated_location_object(self): class Dummy(object): __parent__ = None __name__ = 'before' island = Dummy() self.assertEqual(list(self._callFUT(island)), [island]) def test_w_nested_location_object(self): class Dummy(object): __parent__ = None __name__ = 'before' parent = Dummy() child = Dummy() child.__parent__ = parent grand = Dummy() grand.__parent__ = child self.assertEqual(list(self._callFUT(grand)), [grand, child, parent]) class Test_inside(unittest.TestCase): def _callFUT(self, i1, i2): from zope.location.location import inside return inside(i1, i2) def test_w_non_location_objects(self): island = object() atoll = object() self.assertTrue(self._callFUT(island, island)) self.assertFalse(self._callFUT(island, atoll)) self.assertFalse(self._callFUT(atoll, island)) self.assertTrue(self._callFUT(atoll, atoll)) def test_w_isolated_location_objects(self): class Dummy(object): __parent__ = None __name__ = 'before' island = Dummy() atoll = Dummy() self.assertTrue(self._callFUT(island, island)) self.assertFalse(self._callFUT(island, atoll)) self.assertFalse(self._callFUT(atoll, island)) self.assertTrue(self._callFUT(atoll, atoll)) def test_w_nested_location_object(self): class Dummy(object): __parent__ = None __name__ = 'before' parent = Dummy() child = Dummy() child.__parent__ = parent grand = Dummy() grand.__parent__ = child self.assertTrue(self._callFUT(child, parent)) self.assertFalse(self._callFUT(parent, child)) self.assertTrue(self._callFUT(child, child)) self.assertTrue(self._callFUT(grand, parent)) self.assertFalse(self._callFUT(parent, grand)) self.assertTrue(self._callFUT(grand, child)) self.assertFalse(self._callFUT(child, grand)) self.assertTrue(self._callFUT(grand, grand)) class ClassAndInstanceDescrTests(unittest.TestCase): def _getTargetClass(self): from zope.location.location import ClassAndInstanceDescr return ClassAndInstanceDescr def _makeOne(self, _inst, _class): return self._getTargetClass()(_inst, _class) def _makeScaffold(self): _inst_called = [] def _inst(*args, **kw): _inst_called.append((args, kw)) return 'INST' _class_called = [] def _class(*args, **kw): _class_called.append((args, kw)) return 'CLASS' class Foo(object): descr = self._makeOne(_inst, _class) return Foo, _class_called, _inst_called def test_fetched_from_class(self): Foo, _class_called, _inst_called = self._makeScaffold() self.assertEqual(Foo.descr, 'CLASS') self.assertEqual(_class_called, [((Foo,),{})]) self.assertEqual(_inst_called, []) def test_fetched_from_instance(self): Foo, _class_called, _inst_called = self._makeScaffold() foo = Foo() self.assertEqual(foo.descr, 'INST') self.assertEqual(_class_called, []) self.assertEqual(_inst_called, [((foo,),{})]) _MARKER = object() class LocationProxyTests(unittest.TestCase, ConformsToILocation): def _getTargetClass(self): from zope.location.location import LocationProxy return LocationProxy def _makeOne(self, obj=None, container=_MARKER, name=_MARKER): if obj is None: obj = object() if container is _MARKER: if name is _MARKER: return self._getTargetClass()(obj) return self._getTargetClass()(obj, name=name) if name is _MARKER: return self._getTargetClass()(obj, container) return self._getTargetClass()(obj, container, name) def test_ctor_defaults(self): dummy = object() # can't setattr proxy = self._makeOne(dummy) self.assertEqual(proxy.__parent__, None) self.assertEqual(proxy.__name__, None) def test_ctor_explicit(self): dummy = object() # can't setattr parent = object() proxy = self._makeOne(dummy, parent, 'name') self.assertTrue(proxy.__parent__ is parent) self.assertEqual(proxy.__name__, 'name') def test___getattribute___wrapped(self): class Context(object): attr = 'ATTR' context = Context() proxy = self._makeOne(context) self.assertEqual(proxy.attr, 'ATTR') def test___setattr___wrapped(self): class Context(object): attr = 'BEFORE' context = Context() proxy = self._makeOne(context) proxy.attr = 'AFTER' self.assertEqual(context.attr, 'AFTER') def test___doc___from_derived_class(self): klass = self._getTargetClass() class Derived(klass): """DERIVED""" self.assertEqual(Derived.__doc__, 'DERIVED') def test___doc___from_target_class(self): klass = self._getTargetClass() class Derived(klass): """DERIVED""" class Context(object): """CONTEXT""" proxy = self._makeOne(Context()) self.assertEqual(proxy.__doc__, 'CONTEXT') def test___doc___from_target_instance(self): klass = self._getTargetClass() class Derived(klass): """DERIVED""" class Context(object): """CONTEXT""" context = Context() context.__doc__ = 'INSTANCE' proxy = self._makeOne(context) self.assertEqual(proxy.__doc__, 'INSTANCE') def test___reduce__(self): proxy = self._makeOne() self.assertRaises(TypeError, proxy.__reduce__) def test___reduce_ex__(self): proxy = self._makeOne() self.assertRaises(TypeError, proxy.__reduce_ex__, 1) def test___reduce___via_pickling(self): import pickle class Context(object): def __reduce__(self): return {'a': 1} proxy = self._makeOne(Context()) # XXX: this TypeError is not due to LocationProxy.__reduce__: # it's descriptor (under pure Python) isn't begin triggered # properly self.assertRaises(TypeError, pickle.dumps, proxy) def test__providedBy___class(self): from zope.interface import Interface from zope.interface import implementer from zope.interface import providedBy from zope.interface import provider class IProxyFactory(Interface): pass class IProxy(Interface): pass @provider(IProxyFactory) @implementer(IProxy) class Foo(self._getTargetClass()): pass self.assertEqual(list(providedBy(Foo)), [IProxyFactory]) def test__providedBy___instance(self): from zope.interface import Interface from zope.interface import implementer from zope.interface import providedBy from zope.interface import provider from zope.location.interfaces import ILocation class IProxyFactory(Interface): pass class IProxy(Interface): pass class IContextFactory(Interface): pass class IContext(Interface): pass @provider(IProxyFactory) @implementer(IProxy) class Proxy(self._getTargetClass()): pass @provider(IContextFactory) @implementer(IContext) class Context(object): pass context = Context() proxy = Proxy(context) self.assertEqual(list(providedBy(proxy)), [IContext, IProxy, ILocation]) class LocationPyProxyTests(LocationProxyTests): def setUp(self): import sys for mod in ('zope.location.location', 'zope.proxy.decorator'): try: del sys.modules[mod] except KeyError: pass import zope.proxy self.orig = (zope.proxy.ProxyBase, zope.proxy.getProxiedObject, zope.proxy.setProxiedObject, zope.proxy.isProxy, zope.proxy.sameProxiedObjects, zope.proxy.queryProxy, zope.proxy.queryInnerProxy, zope.proxy.removeAllProxies, zope.proxy.non_overridable) zope.proxy.ProxyBase = zope.proxy.PyProxyBase zope.proxy.getProxiedObject = zope.proxy.py_getProxiedObject zope.proxy.setProxiedObject = zope.proxy.py_setProxiedObject zope.proxy.isProxy = zope.proxy.py_isProxy zope.proxy.sameProxiedObjects = zope.proxy.py_sameProxiedObjects zope.proxy.queryProxy = zope.proxy.py_queryProxy zope.proxy.queryInnerProxy = zope.proxy.py_queryInnerProxy zope.proxy.removeAllProxies = zope.proxy.py_removeAllProxies zope.proxy.non_overridable = zope.proxy.PyNonOverridable def tearDown(self): import zope.proxy (zope.proxy.ProxyBase, zope.proxy.getProxiedObject, zope.proxy.setProxiedObject, zope.proxy.isProxy, zope.proxy.sameProxiedObjects, zope.proxy.queryProxy, zope.proxy.queryInnerProxy, zope.proxy.removeAllProxies, zope.proxy.non_overridable) = self.orig def test_suite(): return unittest.TestSuite(( unittest.makeSuite(LocationTests), unittest.makeSuite(Test_locate), unittest.makeSuite(Test_located), unittest.makeSuite(Test_inside), unittest.makeSuite(Test_LocationIterator), unittest.makeSuite(ClassAndInstanceDescrTests), # In case of Python-only version, tests are simply run twice. unittest.makeSuite(LocationProxyTests), unittest.makeSuite(LocationPyProxyTests), )) zope.location-4.0.3/src/zope/location/tests/test_configure.py0000664000175000017500000000317512073042223024321 0ustar tseavertseaver############################################################################## # # Copyright (c) 2003-2009 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Test ZCML loading """ import unittest class Test_ZCML_loads(unittest.TestCase): def test_it(self): try: import zope.component # no registrations made if not present except ImportError: ADAPTERS_REGISTERED = 0 else: ADAPTERS_REGISTERED = 4 try: from zope.configuration.xmlconfig import _clearContext from zope.configuration.xmlconfig import _getContext from zope.configuration.xmlconfig import XMLConfig except ImportError: pass else: import zope.location _clearContext() context = _getContext() XMLConfig('configure.zcml', zope.location) adapters = ([x for x in context.actions if x['discriminator'] is not None]) self.assertEqual(len(adapters), ADAPTERS_REGISTERED) def test_suite(): return unittest.TestSuite(( unittest.makeSuite(Test_ZCML_loads), )) zope.location-4.0.3/src/zope/location/tests/test_pickling.py0000664000175000017500000000452612073042223024141 0ustar tseavertseaver############################################################################## # # Copyright (c) 2012 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## import unittest try: import zope.copy except ImportError: def test_suite(): return unittest.TestSuite() else: class LocationCopyHookTests(unittest.TestCase): def _getTargetClass(self): from zope.location.pickling import LocationCopyHook return LocationCopyHook def _makeOne(self, obj=None): if obj is None: obj = object() return self._getTargetClass()(obj) def test_class_conforms_to_ICopyHook(self): from zope.interface.verify import verifyClass from zope.copy.interfaces import ICopyHook verifyClass(ICopyHook, self._getTargetClass()) def test_instance_conforms_to_ICopyHook(self): from zope.interface.verify import verifyObject from zope.copy.interfaces import ICopyHook verifyObject(ICopyHook, self._makeOne()) def test___call___w_context_inside_toplevel(self): from zope.copy.interfaces import ResumeCopy class Dummy(object): __parent__ = __name__ = None top_level = Dummy() context = Dummy() context.__parent__ = top_level hook = self._makeOne(context) self.assertRaises(ResumeCopy, hook, top_level, object()) def test___call___w_context_outside_toplevel(self): class Dummy(object): __parent__ = __name__ = None top_level = Dummy() context = Dummy() hook = self._makeOne(context) self.assertTrue(hook(top_level, object()) is context) def test_suite(): return unittest.TestSuite(( unittest.makeSuite(LocationCopyHookTests), )) zope.location-4.0.3/src/zope/location/traversing.py0000664000175000017500000001075112073042223022321 0ustar tseavertseaver############################################################################## # # Copyright (c) 2003-2009 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Classes to support implenting IContained """ __docformat__ = 'restructuredtext' from zope.interface import implementer from zope.location.interfaces import ILocationInfo from zope.location.interfaces import IRoot from zope.location.interfaces import ISite # zope.component, if present from zope.location._compat import u @implementer(ILocationInfo) class LocationPhysicallyLocatable(object): """Provide location information for location objects """ def __init__(self, context): self.context = context def getRoot(self): """See ILocationInfo. """ context = self.context max = 9999 while context is not None: if IRoot.providedBy(context): return context context = context.__parent__ max -= 1 if max < 1: raise TypeError("Maximum location depth exceeded, " "probably due to a a location cycle.") raise TypeError("Not enough context to determine location root") def getPath(self): """See ILocationInfo. """ path = [] context = self.context max = 9999 while context is not None: if IRoot.providedBy(context): if path: path.append('') path.reverse() return u('/').join(path) else: return u('/') path.append(context.__name__) context = context.__parent__ max -= 1 if max < 1: raise TypeError("Maximum location depth exceeded, " "probably due to a a location cycle.") raise TypeError("Not enough context to determine location root") def getParent(self): """See ILocationInfo. """ parent = getattr(self.context, '__parent__', None) if parent is not None: return parent raise TypeError('Not enough context information to get parent', self.context) def getParents(self): """See ILocationInfo. """ # XXX Merge this implementation with getPath. This was refactored # from zope.traversing. parents = [] w = self.context while 1: w = getattr(w, '__parent__', None) if w is None: break parents.append(w) if parents and IRoot.providedBy(parents[-1]): return parents raise TypeError("Not enough context information to get all parents") def getName(self): """See ILocationInfo """ return self.context.__name__ def getNearestSite(self): """See ILocationInfo """ if ISite.providedBy(self.context): return self.context for parent in self.getParents(): if ISite.providedBy(parent): return parent return self.getRoot() @implementer(ILocationInfo) class RootPhysicallyLocatable(object): """Provide location information for the root object This adapter is very simple, because there's no places to search for parents and nearest sites, so we are only working with context object, knowing that its the root object already. """ def __init__(self, context): self.context = context def getRoot(self): """See ILocationInfo """ return self.context def getPath(self): """See ILocationInfo """ return u('/') def getParent(self): """See ILocationInfo. """ return None def getParents(self): """See ILocationInfo """ return [] def getName(self): """See ILocationInfo """ return u('') def getNearestSite(self): """See ILocationInfo """ return self.context zope.location-4.0.3/src/zope/location/configure.zcml0000664000175000017500000000124712073042223022433 0ustar tseavertseaver zope.location-4.0.3/src/zope/location/location.py0000664000175000017500000000722312167130545021756 0ustar tseavertseaver############################################################################## # # Copyright (c) 2003-2009 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Location support """ __docformat__ = 'restructuredtext' from zope.interface import implementer from zope.proxy import ProxyBase from zope.proxy import getProxiedObject from zope.proxy import non_overridable from zope.proxy.decorator import DecoratorSpecificationDescriptor from zope.location.interfaces import ILocation @implementer(ILocation) class Location(object): """Mix-in that implements ILocation. It provides the `__parent__` and `__name__` attributes. """ __parent__ = None __name__ = None def locate(obj, parent, name=None): """Update a location's coordinates.""" obj.__parent__ = parent obj.__name__ = name def located(obj, parent, name=None): """Ensure and return the location of an object. Updates the location's coordinates. """ location = ILocation(obj) locate(location, parent, name) return location def LocationIterator(object): """Iterate over an object and all of its parents.""" while object is not None: yield object object = getattr(object, '__parent__', None) def inside(l1, l2): """Test whether l1 is a successor of l2. l1 is a successor of l2 if l2 is in the chain of parents of l1 or l2 is l1. """ while l1 is not None: if l1 is l2: return True l1 = getattr(l1, '__parent__', None) return False class ClassAndInstanceDescr(object): def __init__(self, *args): self.funcs = args def __get__(self, inst, cls): if inst is None: return self.funcs[1](cls) return self.funcs[0](inst) @implementer(ILocation) class LocationProxy(ProxyBase): """Location-object proxy This is a non-picklable proxy that can be put around objects that don't implement `ILocation`. """ __slots__ = ('__parent__', '__name__') __safe_for_unpickling__ = True __doc__ = ClassAndInstanceDescr( lambda inst: getProxiedObject(inst).__doc__, lambda cls, __doc__ = __doc__: __doc__, ) def __new__(self, ob, container=None, name=None): return ProxyBase.__new__(self, ob) def __init__(self, ob, container=None, name=None): ProxyBase.__init__(self, ob) self.__parent__ = container self.__name__ = name def __getattribute__(self, name): if name in LocationProxy.__dict__: return object.__getattribute__(self, name) return ProxyBase.__getattribute__(self, name) def __setattr__(self, name, value): if name in self.__slots__ + getattr(ProxyBase, '__slots__', ()): #('_wrapped', '__parent__', '__name__'): try: return object.__setattr__(self, name, value) except TypeError: #pragma NO COVER C Optimization return ProxyBase.__setattr__(self, name, value) return ProxyBase.__setattr__(self, name, value) @non_overridable def __reduce__(self, proto=None): raise TypeError("Not picklable") __reduce_ex__ = __reduce__ __providedBy__ = DecoratorSpecificationDescriptor() zope.location-4.0.3/src/zope/__init__.py0000664000175000017500000000007012073042223020055 0ustar tseavertseaver__import__('pkg_resources').declare_namespace(__name__) zope.location-4.0.3/COPYRIGHT.txt0000664000175000017500000000004012073042223016306 0ustar tseavertseaverZope Foundation and Contributorszope.location-4.0.3/CHANGES.rst0000664000175000017500000001347212312364610016017 0ustar tseavertseaver======= CHANGES ======= 4.0.3 (2014-03-19) ------------------ - Added Python 3.4 support. - Updated ``boostrap.py`` to version 2.2. 4.0.2 (2013-03-11) ------------------ - Changed the behavior of ``LocationProxy``'s ``__setattr__()`` to correctly behave when dealing with the pure Python version of the ``ProxyBase`` class. Also added a test suite that fully tests the pure Python proxy version of the ``LocationProxy`` class. 4.0.1 (2013-02-19) ------------------ - Added Python 3.3 support. 4.0.0 (2012-06-07) ------------------ - Removed backward-compatibility imports: - ``zope.copy.clone`` (aliased as ``zope.location.pickling.locationCopy``) - ``zope.copy.CopyPersistent`` (aliased as ``zope.location.pickling.CopyPersistent``). - ``zope.site.interfaces.IPossibleSite`` (aliased as ``zope.location.interfaces.IPossibleSite``). - Added Python 3.2 support. - Made ``zope.component`` dependency optional. Use the ``component`` extra to force its installation (or just require it directly). If ``zope.component`` is not present, this package defines the ``ISite`` interface itself, and omits adapter registrations from its ZCML. - Added support for PyPy. - Added support for continuous integration using ``tox`` and ``jenkins``. - 100% unit test coverage. - Added Sphinx documentation: moved doctest examples to API reference. - Added 'setup.py docs' alias (installs ``Sphinx`` and dependencies). - Added 'setup.py dev' alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Replaced deprecated ``zope.component.adapts`` usage with equivalent ``zope.component.adapter`` decorator. - Replaced deprecated ``zope.interface.implements`` usage with equivalent ``zope.interface.implementer`` decorator. - Dropped support for Python 2.4 and 2.5. 3.9.1 (2011-08-22) ------------------ - Added zcml extra as well as a test for configure.zcml. 3.9.0 (2009-12-29) ------------------ - Moved LocationCopyHook related tests to zope.copy and remove a test dependency on that package. 3.8.2 (2009-12-23) ------------------ - Fixed a typo in the configure.zcml. 3.8.1 (2009-12-23) ------------------ - Removed dependency on zope.copy: the LocationCopyHook adapter is registered only if zope.copy is available. - Use the standard Python doctest module instead of zope.testing.doctest, which has been deprecated. 3.8.0 (2009-12-22) ------------------ - Adjusted to testing output caused by new zope.schema. 3.7.1 (2009-11-18) ------------------ - Moved the IPossibleSite and ISite interfaces to zope.component as they are dealing with zope.component's concept of a site, but not with location. 3.7.0 (2009-09-29) ------------------ - Added getParent() to ILocationInfo and moved the actual implementation here from zope.traversal.api, analogous to getParents(). - Actually removed deprecated PathPersistent class from zope.location.pickling. - Moved ITraverser back to zope.traversing where it belongs conceptually. The interface had been moved to zope.location to invert the package interdependency but is no longer used here. 3.6.0 (2009-08-27) ------------------ - New feature release: deprecated locationCopy, CopyPersistent and PathPersistent from zope.location.pickling. These changes were already part of the 3.5.3 release, which was erroneously numbered as a bugfix relese. - Removed dependency on zope.deferredimport, directly import deprecated modules without using it. 3.5.5 (2009-08-15) ------------------ - Add zope.deferredimport as a dependency as it's used directly by zope.location.pickling. 3.5.4 (2009-05-17) ------------------ - Add ``IContained`` interface to ``zope.location.interfaces`` module. This interface was moved from ``zope.container`` (after ``zope.container`` 3.8.2); consumers of ``IContained`` may now depend on zope.location rather than zope.container to reduce dependency cycles. 3.5.3 (2009-02-09) ------------------ - Use new zope.copy package for implementing location copying. Thus there's changes in the ``zope.locaton.pickling`` module: * The ``locationCopy`` and ``CopyPersistent`` was removed in prefer to their equivalents in zope.copy. Deprecated backward-compatibility imports provided. * The module now provides a ``zope.copy.interfaces.ICopyHook`` adapter for ``ILocation`` objects that replaces the old CopyPersistent functionality of checking for the need to clone objects based on their location. 3.5.2 (2009-02-04) ------------------ - Split RootPhysicallyLocatable adapter back from LocationPhysicallyLocatable, because the IRoot object may not always provide ILocation and the code for the root object is also simplier. It's basically a copy of the RootPhysicallyLocatable adapter from zope.traversing version 3.5.0 and below with ``getParents`` method added (returns an empty list). 3.5.1 (2009-02-02) ------------------ - Improve test coverage. - The new ``getParents`` method was extracted from ``zope.traversing`` and added to ILocationInfo interface in the previous release. Custom ILocationInfo implementations should make sure they have this method as well. That method is already used in ``zope.traversing.api.getParents`` function. - Make ``getName`` of LocationPhysicallyLocatable always return empty string for the IRoot object, like RootPhysicallyLocatable from ``zope.traversing`` did. So, now LocationPhysicallyLocatable is fully compatible with RootPhysicallyLocatable, making the latter one obsolete. - Change package mailing list address to zope-dev at zope.org instead of retired zope3-dev at zope.org. 3.5.0 (2009-01-31) ------------------ - Reverse the dependency between zope.location and zope.traversing. This also causes the dependency to various other packages go away. 3.4.0 (2007-10-02) ------------------ - Initial release independent of the main Zope tree. zope.location-4.0.3/LICENSE.txt0000664000175000017500000000402612073042223016030 0ustar tseavertseaverZope Public License (ZPL) Version 2.1 A copyright notice accompanies this license document that identifies the copyright holders. This license has been certified as open source. It has also been designated as GPL compatible by the Free Software Foundation (FSF). Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions in source code must retain the accompanying copyright notice, this list of conditions, and the following disclaimer. 2. Redistributions in binary form must reproduce the accompanying copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Names of the copyright holders must not be used to endorse or promote products derived from this software without prior written permission from the copyright holders. 4. The right to distribute this software or to use it for any purpose does not give you the right to use Servicemarks (sm) or Trademarks (tm) of the copyright holders. Use of them is covered by separate agreement with the copyright holders. 5. If any files are modified, you must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. Disclaimer THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. zope.location-4.0.3/README.rst0000664000175000017500000000016712073042223015676 0ustar tseavertseaverZope Location ============= Overview ======== In Zope3, location are special objects that has a structural location. zope.location-4.0.3/docs/0000775000175000017500000000000012312364651015143 5ustar tseavertseaverzope.location-4.0.3/docs/api.rst0000664000175000017500000002517312073042223016446 0ustar tseavertseaver:mod:`zope.location` API ======================== :mod:`zope.location.interfaces` ------------------------------- .. automodule:: zope.location.interfaces .. autointerface:: ILocation :members: :member-order: bysource .. autointerface:: IContained :members: :member-order: bysource .. autointerface:: ILocationInfo :members: :member-order: bysource .. autointerface:: ISublocations :members: :member-order: bysource .. autointerface:: IRoot :members: :member-order: bysource .. autoexception:: LocationError :members: :member-order: bysource :mod:`zope.location.location` ----------------------------- .. automodule:: zope.location.location .. autoclass:: Location :members: :member-order: bysource .. autofunction:: locate .. autofunction:: located .. autofunction:: LocationIterator .. autofunction:: inside .. autoclass:: LocationProxy :members: :member-order: bysource :mod:`zope.location.traversing` ------------------------------- .. automodule:: zope.location.traversing .. autoclass:: LocationPhysicallyLocatable .. doctest:: >>> from zope.interface.verify import verifyObject >>> from zope.location.interfaces import ILocationInfo >>> from zope.location.location import Location >>> from zope.location.traversing import LocationPhysicallyLocatable >>> info = LocationPhysicallyLocatable(Location()) >>> verifyObject(ILocationInfo, info) True .. automethod:: getRoot .. doctest:: >>> from zope.interface import directlyProvides >>> from zope.location.interfaces import IRoot >>> from zope.location.location import Location >>> from zope.location.traversing import LocationPhysicallyLocatable >>> root = Location() >>> directlyProvides(root, IRoot) >>> LocationPhysicallyLocatable(root).getRoot() is root True >>> o1 = Location(); o1.__parent__ = root >>> LocationPhysicallyLocatable(o1).getRoot() is root True >>> o2 = Location(); o2.__parent__ = o1 >>> LocationPhysicallyLocatable(o2).getRoot() is root True We'll get a TypeError if we try to get the location fo a rootless object: .. doctest:: >>> o1.__parent__ = None >>> LocationPhysicallyLocatable(o1).getRoot() Traceback (most recent call last): ... TypeError: Not enough context to determine location root >>> LocationPhysicallyLocatable(o2).getRoot() Traceback (most recent call last): ... TypeError: Not enough context to determine location root If we screw up and create a location cycle, it will be caught: .. doctest:: >>> o1.__parent__ = o2 >>> LocationPhysicallyLocatable(o1).getRoot() Traceback (most recent call last): ... TypeError: Maximum location depth exceeded, probably due to a a location cycle. .. automethod:: getPath .. doctest:: >>> from zope.interface import directlyProvides >>> from zope.location.interfaces import IRoot >>> from zope.location.location import Location >>> from zope.location.traversing import LocationPhysicallyLocatable >>> root = Location() >>> directlyProvides(root, IRoot) >>> LocationPhysicallyLocatable(root).getPath() u'/' >>> o1 = Location(); o1.__parent__ = root; o1.__name__ = 'o1' >>> LocationPhysicallyLocatable(o1).getPath() u'/o1' >>> o2 = Location(); o2.__parent__ = o1; o2.__name__ = u'o2' >>> LocationPhysicallyLocatable(o2).getPath() u'/o1/o2' It is an error to get the path of a rootless location: .. doctest:: >>> o1.__parent__ = None >>> LocationPhysicallyLocatable(o1).getPath() Traceback (most recent call last): ... TypeError: Not enough context to determine location root >>> LocationPhysicallyLocatable(o2).getPath() Traceback (most recent call last): ... TypeError: Not enough context to determine location root If we screw up and create a location cycle, it will be caught: .. doctest:: >>> o1.__parent__ = o2 >>> LocationPhysicallyLocatable(o1).getPath() Traceback (most recent call last): ... TypeError: Maximum location depth exceeded, """ \ """probably due to a a location cycle. .. automethod:: getParent .. doctest:: >>> from zope.interface import directlyProvides >>> from zope.location.interfaces import IRoot >>> from zope.location.location import Location >>> from zope.location.traversing import LocationPhysicallyLocatable >>> root = Location() >>> directlyProvides(root, IRoot) >>> o1 = Location() >>> o2 = Location() >>> LocationPhysicallyLocatable(o2).getParent() # doctest: +ELLIPSIS Traceback (most recent call last): TypeError: ('Not enough context information to get parent', ) >>> o1.__parent__ = root >>> LocationPhysicallyLocatable(o1).getParent() == root True >>> o2.__parent__ = o1 >>> LocationPhysicallyLocatable(o2).getParent() == o1 True .. automethod:: getParents .. doctest:: >>> from zope.interface import directlyProvides >>> from zope.interface import noLongerProvides >>> from zope.location.interfaces import IRoot >>> from zope.location.location import Location >>> from zope.location.traversing import LocationPhysicallyLocatable >>> root = Location() >>> directlyProvides(root, IRoot) >>> o1 = Location() >>> o2 = Location() >>> o1.__parent__ = root >>> o2.__parent__ = o1 >>> LocationPhysicallyLocatable(o2).getParents() == [o1, root] True If the last parent is not an IRoot object, TypeError will be raised as statet before. >>> noLongerProvides(root, IRoot) >>> LocationPhysicallyLocatable(o2).getParents() Traceback (most recent call last): ... TypeError: Not enough context information to get all parents .. automethod:: getName .. doctest:: >>> from zope.location.location import Location >>> from zope.location.traversing import LocationPhysicallyLocatable >>> o1 = Location(); o1.__name__ = u'o1' >>> LocationPhysicallyLocatable(o1).getName() u'o1' .. automethod:: getNearestSite .. doctest:: >>> from zope.interface import directlyProvides >>> from zope.component.interfaces import ISite >>> from zope.location.interfaces import IRoot >>> from zope.location.location import Location >>> from zope.location.traversing import LocationPhysicallyLocatable >>> o1 = Location() >>> o1.__name__ = 'o1' >>> LocationPhysicallyLocatable(o1).getNearestSite() Traceback (most recent call last): ... TypeError: Not enough context information to get all parents >>> root = Location() >>> directlyProvides(root, IRoot) >>> o1 = Location() >>> o1.__name__ = 'o1' >>> o1.__parent__ = root >>> LocationPhysicallyLocatable(o1).getNearestSite() is root True >>> directlyProvides(o1, ISite) >>> LocationPhysicallyLocatable(o1).getNearestSite() is o1 True >>> o2 = Location() >>> o2.__parent__ = o1 >>> LocationPhysicallyLocatable(o2).getNearestSite() is o1 True .. autoclass:: RootPhysicallyLocatable .. doctest:: >>> from zope.interface.verify import verifyObject >>> from zope.location.interfaces import ILocationInfo >>> from zope.location.traversing import RootPhysicallyLocatable >>> info = RootPhysicallyLocatable(None) >>> verifyObject(ILocationInfo, info) True .. automethod:: getRoot No need to search for root when our context is already root :) .. doctest:: >>> from zope.location.traversing import RootPhysicallyLocatable >>> o1 = object() >>> RootPhysicallyLocatable(o1).getRoot() is o1 True .. automethod:: getPath Root object is at the top of the tree, so always return ``/``. .. doctest:: >>> from zope.location.traversing import RootPhysicallyLocatable >>> o1 = object() >>> RootPhysicallyLocatable(o1).getPath() u'/' .. automethod:: getParent Returns None if the object is a containment root. Raises TypeError if the object doesn't have enough context to get the parent. .. doctest:: >>> from zope.location.traversing import RootPhysicallyLocatable >>> o1 = object() >>> RootPhysicallyLocatable(o1).getParent() is None True .. automethod:: getParents There's no parents for the root object, return empty list. .. doctest:: >>> from zope.location.traversing import RootPhysicallyLocatable >>> o1 = object() >>> RootPhysicallyLocatable(o1).getParents() [] .. automethod:: getName Always return empty unicode string for the root object .. doctest:: >>> from zope.location.traversing import RootPhysicallyLocatable >>> o1 = object() >>> RootPhysicallyLocatable(o1).getName() u'' .. automethod:: getNearestSite Return object itself as the nearest site, because there's no other place to look for. It's also usual that the root is the site as well. .. doctest:: >>> from zope.location.traversing import RootPhysicallyLocatable >>> o1 = object() >>> RootPhysicallyLocatable(o1).getNearestSite() is o1 True zope.location-4.0.3/docs/make.bat0000664000175000017500000001176412073042223016551 0ustar tseavertseaver@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . set I18NSPHINXOPTS=%SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. texinfo to make Texinfo files echo. gettext to make PO message catalogs echo. changes to make an overview over all changed/added/deprecated items echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\zopelocation.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\zopelocation.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "texinfo" ( %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo if errorlevel 1 exit /b 1 echo. echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. goto end ) if "%1" == "gettext" ( %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale if errorlevel 1 exit /b 1 echo. echo.Build finished. The message catalogs are in %BUILDDIR%/locale. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) :end zope.location-4.0.3/docs/Makefile0000664000175000017500000001272412073042223016601 0ustar tseavertseaver# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/zopelocation.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/zopelocation.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/zopelocation" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/zopelocation" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." zope.location-4.0.3/docs/conf.py0000664000175000017500000001750612073042223016443 0ustar tseavertseaver# -*- coding: utf-8 -*- # # zope.location documentation build configuration file, created by # sphinx-quickstart on Wed Jun 6 17:47:12 2012. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode', 'repoze.sphinx.autointerface', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'zope.location' copyright = u'2012, Zope Foundation Contributors' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '4.0' # The full version, including alpha/beta/rc tags. release = '4.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'zopelocationdoc' # -- Options for LaTeX output -------------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'zopelocation.tex', u'zope.location Documentation', u'Zope Foundation Contributors', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'zopelocation', u'zope.location Documentation', [u'Zope Foundation Contributors'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------------ # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'zopelocation', u'zope.location Documentation', u'Zope Foundation Contributors', 'zopelocation', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' zope.location-4.0.3/docs/index.rst0000664000175000017500000000030112073042223016766 0ustar tseavertseaver:mod:`zope.location` ==================== Contents: .. toctree:: :maxdepth: 2 narr api Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` zope.location-4.0.3/docs/narr.rst0000664000175000017500000001113312073042223016626 0ustar tseavertseaverUsing :mod:`zope.location` ========================== :class:`~zope.location.location.Location` ----------------------------------------- The `Location` base class is a mix-in that defines `__parent__` and `__name__` attributes. Usage within an Object field: .. doctest:: >>> from zope.interface import implementer, Interface >>> from zope.schema import Object >>> from zope.schema.fieldproperty import FieldProperty >>> from zope.location.interfaces import ILocation >>> from zope.location.location import Location >>> class IA(Interface): ... location = Object(schema=ILocation, required=False, default=None) >>> @implementer(IA) ... class A(object): ... location = FieldProperty(IA['location']) >>> a = A() >>> a.location = Location() >>> loc = Location(); loc.__name__ = u'foo' >>> a.location = loc >>> loc = Location(); loc.__name__ = None >>> a.location = loc >>> loc = Location(); loc.__name__ = 'foo' >>> a.location = loc Traceback (most recent call last): ... WrongContainedType: ([WrongType('foo', , '__name__')], 'location') :func:`~zope.location.location.inside` -------------------------------------- The `inside` function tells if l1 is inside l2. L1 is inside l2 if l2 is an ancestor of l1. .. doctest:: >>> o1 = Location() >>> o2 = Location(); o2.__parent__ = o1 >>> o3 = Location(); o3.__parent__ = o2 >>> o4 = Location(); o4.__parent__ = o3 >>> from zope.location.location import inside >>> inside(o1, o1) True >>> inside(o2, o1) True >>> inside(o3, o1) True >>> inside(o4, o1) True >>> inside(o1, o4) False >>> inside(o1, None) False :class:`~zope.location.location.LocationProxy` ---------------------------------------------- `LocationProxy` is a non-picklable proxy that can be put around objects that don't implement `ILocation`. .. doctest:: >>> from zope.location.location import LocationProxy >>> l = [1, 2, 3] >>> ILocation.providedBy(l) False >>> p = LocationProxy(l, "Dad", "p") >>> p [1, 2, 3] >>> ILocation.providedBy(p) True >>> p.__parent__ 'Dad' >>> p.__name__ 'p' >>> import pickle >>> p2 = pickle.dumps(p) Traceback (most recent call last): ... TypeError: Not picklable Proxies should get their doc strings from the object they proxy: .. doctest:: >>> p.__doc__ == l.__doc__ True If we get a "located class" somehow, its doc string well be available through proxy as well: .. doctest:: >>> class LocalClass(object): ... """This is class that can be located""" >>> p = LocationProxy(LocalClass) >>> p.__doc__ == LocalClass.__doc__ True :func:`~zope.location.location.LocationInterator` ------------------------------------------------- This function allows us to iterate over object and all its parents. .. doctest:: >>> from zope.location.location import LocationIterator >>> o1 = Location() >>> o2 = Location() >>> o3 = Location() >>> o3.__parent__ = o2 >>> o2.__parent__ = o1 >>> iter = LocationIterator(o3) >>> iter.next() is o3 True >>> iter.next() is o2 True >>> iter.next() is o1 True >>> iter.next() Traceback (most recent call last): ... StopIteration :func:`~zope.location.location.located` --------------------------------------- `located` locates an object in another and returns it: .. doctest:: >>> from zope.location.location import located >>> a = Location() >>> parent = Location() >>> a_located = located(a, parent, 'a') >>> a_located is a True >>> a_located.__parent__ is parent True >>> a_located.__name__ 'a' If we locate the object again, nothing special happens: .. doctest:: >>> a_located_2 = located(a_located, parent, 'a') >>> a_located_2 is a_located True If the object does not provide ILocation an adapter can be provided: .. doctest:: >>> import zope.interface >>> import zope.component >>> sm = zope.component.getGlobalSiteManager() >>> sm.registerAdapter(LocationProxy, required=(zope.interface.Interface,)) >>> l = [1, 2, 3] >>> parent = Location() >>> l_located = located(l, parent, 'l') >>> l_located.__parent__ is parent True >>> l_located.__name__ 'l' >>> l_located is l False >>> type(l_located) >>> l_located_2 = located(l_located, parent, 'l') >>> l_located_2 is l_located True When changing the name, we still do not get a different proxied object: .. doctest:: >>> l_located_3 = located(l_located, parent, 'new-name') >>> l_located_3 is l_located_2 True >>> sm.unregisterAdapter(LocationProxy, required=(zope.interface.Interface,)) True zope.location-4.0.3/MANIFEST.in0000664000175000017500000000034412167130545015753 0ustar tseavertseaverinclude *.rst include *.txt recursive-include docs * recursive-include src * exclude .coverage exclude nosetests.xml exclude src/coverage.xml global-exclude *.dll global-exclude *.pyc global-exclude *.pyo global-exclude *.so