zope.location-4.2/0000755000076500000240000000000013357130166014033 5ustar macstaff00000000000000zope.location-4.2/bootstrap.py0000644000076500000240000001644213357130166016431 0ustar macstaff00000000000000############################################################################## # # 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 __version__ = '2015-07-01' # See zc.buildout's changelog if this version is up to date. tmpeggs = tempfile.mkdtemp(prefix='bootstrap-') 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("--version", action="store_true", default=False, help=("Return bootstrap.py 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")) parser.add_option("--allow-site-packages", action="store_true", default=False, help=("Let bootstrap.py use existing site packages")) parser.add_option("--buildout-version", help="Use a specific zc.buildout version") parser.add_option("--setuptools-version", help="Use a specific setuptools version") parser.add_option("--setuptools-to-dir", help=("Allow for re-use of existing directory of " "setuptools versions")) options, args = parser.parse_args() if options.version: print("bootstrap.py version %s" % __version__) sys.exit(0) ###################################################################### # load/install setuptools try: from urllib.request import urlopen except ImportError: from urllib2 import urlopen ez = {} if os.path.exists('ez_setup.py'): exec(open('ez_setup.py').read(), ez) else: exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez) if not options.allow_site_packages: # ez_setup imports site, which adds site packages # this will remove them from the path to ensure that incompatible versions # of setuptools are not in the path import site # inside a virtualenv, there is no 'getsitepackages'. # We can't remove these reliably if hasattr(site, 'getsitepackages'): for sitepackage_path in site.getsitepackages(): # Strip all site-packages directories from sys.path that # are not sys.prefix; this is because on Windows # sys.prefix is a site-package directory. if sitepackage_path != sys.prefix: sys.path[:] = [x for x in sys.path if sitepackage_path not in x] setup_args = dict(to_dir=tmpeggs, download_delay=0) if options.setuptools_version is not None: setup_args['version'] = options.setuptools_version if options.setuptools_to_dir is not None: setup_args['to_dir'] = options.setuptools_to_dir ez['use_setuptools'](**setup_args) import setuptools 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 setuptools_path = ws.find( pkg_resources.Requirement.parse('setuptools')).location # Fix sys.path here as easy_install.pth added before PYTHONPATH cmd = [sys.executable, '-c', 'import sys; sys.path[0:0] = [%r]; ' % setuptools_path + '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]) requirement = 'zc.buildout' version = options.buildout_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): try: return not parsed_version.is_prerelease except AttributeError: # Older setuptools 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) != 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.2/PKG-INFO0000644000076500000240000002477113357130166015143 0ustar macstaff00000000000000Metadata-Version: 2.1 Name: zope.location Version: 4.2 Summary: Zope Location Home-page: http://github.com/zopefoundation/zope.location/ Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Description: =================== ``zope.location`` =================== .. image:: https://img.shields.io/pypi/v/zope.location.svg :target: https://pypi.python.org/pypi/zope.location/ :alt: Latest release .. image:: https://img.shields.io/pypi/pyversions/zope.location.svg :target: https://pypi.org/project/zope.location/ :alt: Supported Python versions .. image:: https://travis-ci.org/zopefoundation/zope.location.svg?branch=master :target: https://travis-ci.org/zopefoundation/zope.location .. image:: https://coveralls.io/repos/github/zopefoundation/zope.location/badge.svg?branch=master :target: https://coveralls.io/github/zopefoundation/zope.location?branch=master .. image:: https://readthedocs.org/projects/zopelocation/badge/?version=latest :target: http://zopelocation.readthedocs.org/en/latest/ :alt: Documentation Status In Zope3, "locations" are special objects that have a structural location, indicated with ``__name__`` and ``__parent__`` attributes. See `zope.container `_ for a useful extension of this concept to "containers." Documentation is hosted at https://zopelocation.readthedocs.io/en/latest/ ========= Changes ========= 4.2 (2018-10-09) ================ - Add support for Python 3.7. 4.1.0 (2017-08-03) ================== - Drop support for Python 2.6, 3.2 and 3.3. - Add a page to the docs on hacking ``zope.location``. - Note additional documentation dependencies. - Add support for Python 3.5 and 3.6. - Remove internal ``_compat`` implementation module. 4.0.3 (2014-03-19) ================== - Add Python 3.4 support. - Update ``boostrap.py`` to version 2.2. 4.0.2 (2013-03-11) ================== - Change 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) ================== - Add Python 3.3 support. 4.0.0 (2012-06-07) ================== - Remove 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``). - Add Python 3.2 support. - Make ``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. - Add support for PyPy. - Add support for continuous integration using ``tox`` and ``jenkins``. - Bring unit test coverage to 100%. - Add Sphinx documentation: moved doctest examples to API reference. - Add 'setup.py docs' alias (installs ``Sphinx`` and dependencies). - Add 'setup.py dev' alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Replace deprecated ``zope.component.adapts`` usage with equivalent ``zope.component.adapter`` decorator. - Replace deprecated ``zope.interface.implements`` usage with equivalent ``zope.interface.implementer`` decorator. - Drop support for Python 2.4 and 2.5. 3.9.1 (2011-08-22) ================== - Add zcml extra as well as a test for configure.zcml. 3.9.0 (2009-12-29) ================== - Move LocationCopyHook related tests to zope.copy and remove a test dependency on that package. 3.8.2 (2009-12-23) ================== - Fix a typo in the configure.zcml. 3.8.1 (2009-12-23) ================== - Remove 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) ================== - Adjust to testing output caused by new zope.schema. 3.7.1 (2009-11-18) ================== - Move 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) ================== - Add getParent() to ILocationInfo and moved the actual implementation here from zope.traversal.api, analogous to getParents(). - Actually remove deprecated PathPersistent class from zope.location.pickling. - Move 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: deprecate 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. - Remove 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.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 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 Provides-Extra: test Provides-Extra: docs Provides-Extra: component Provides-Extra: zcml zope.location-4.2/rtd.txt0000644000076500000240000000015613357130166015367 0ustar macstaff00000000000000repoze.sphinx.autointerface zope.configuration zope.component zope.copy zope.interface zope.proxy zope.schema zope.location-4.2/COPYRIGHT.txt0000644000076500000240000000004013357130166016136 0ustar macstaff00000000000000Zope Foundation and Contributorszope.location-4.2/buildout.cfg0000644000076500000240000000060113357130166016340 0ustar macstaff00000000000000[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.2/MANIFEST.in0000644000076500000240000000047613357130166015600 0ustar macstaff00000000000000include *.rst include *.txt include *.py include .coveragerc include buildout.cfg include tox.ini include .travis.yml 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 zope.location-4.2/.coveragerc0000644000076500000240000000027613357130166016161 0ustar macstaff00000000000000[run] source = zope.location [report] precision = 2 exclude_lines = pragma: no cover if __name__ == '__main__': raise NotImplementedError self.fail raise AssertionError zope.location-4.2/docs/0000755000076500000240000000000013357130166014763 5ustar macstaff00000000000000zope.location-4.2/docs/index.rst0000644000076500000240000000031413357130166016622 0ustar macstaff00000000000000:mod:`zope.location` ==================== Contents: .. toctree:: :maxdepth: 2 narr api hacking Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` zope.location-4.2/docs/Makefile0000644000076500000240000001272413357130166016431 0ustar macstaff00000000000000# 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.2/docs/conf.py0000644000076500000240000001750613357130166016273 0ustar macstaff00000000000000# -*- 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.2/docs/hacking.rst0000644000076500000240000002165413357130166017131 0ustar macstaff00000000000000Hacking on :mod:`zope.location` =============================== Getting the Code ################ The main repository for :mod:`zope.location` is in the Zope Foundation Github repository: https://github.com/zopefoundation/zope.location You can get a read-only checkout from there: .. code-block:: sh $ git clone https://github.com/zopefoundation/zope.location.git or fork it and get a writeable checkout of your fork: .. code-block:: sh $ git clone git@github.com/jrandom/zope.location.git The project also mirrors the trunk from the Github repository as a Bazaar branch on Launchpad: https://code.launchpad.net/zope.location You can branch the trunk from there using Bazaar: .. code-block:: sh $ bzr branch lp:zope.location Working in a ``virtualenv`` ########################### Installing ---------- If you use the ``virtualenv`` package to create lightweight Python development environments, you can run the tests using nothing more than the ``python`` binary in a virtualenv. First, create a scratch environment: .. code-block:: sh $ /path/to/virtualenv --no-site-packages /tmp/hack-zope.location Next, get this package registered as a "development egg" in the environment: .. code-block:: sh $ /tmp/hack-zope.location/bin/python setup.py develop Running the tests ----------------- Then, you canrun the tests using the build-in ``setuptools`` testrunner: .. code-block:: sh $ /tmp/hack-zope.location/bin/python setup.py test -q ............................................................................... ---------------------------------------------------------------------- Ran 83 tests in 0.037s OK If you have the :mod:`nose` package installed in the virtualenv, you can use its testrunner too: .. code-block:: sh $ /tmp/hack-zope.location/bin/nosetests ....................................................................................... ---------------------------------------------------------------------- Ran 87 tests in 0.037s OK If you have the :mod:`coverage` pacakge installed in the virtualenv, you can see how well the tests cover the code: .. code-block:: sh $ /tmp/hack-zope.location/bin/easy_install nose coverage ... $ /tmp/hack-zope.location/bin/nosetests --with coverage ....................................................................................... Name Stmts Miss Cover Missing -------------------------------------------------------- zope.location 5 0 100% zope.location._compat 2 0 100% zope.location.interfaces 23 0 100% zope.location.location 61 0 100% zope.location.pickling 14 0 100% zope.location.traversing 80 0 100% -------------------------------------------------------- TOTAL 185 0 100% ---------------------------------------------------------------------- Ran 87 tests in 0.315s OK Building the documentation -------------------------- :mod:`zope.location` uses the nifty :mod:`Sphinx` documentation system for building its docs. Using the same virtualenv you set up to run the tests, you can build the docs: .. code-block:: sh $ /tmp/hack-zope.location/bin/easy_install \ Sphinx repoze.sphinx.autoitnerface zope.component ... $ cd docs $ PATH=/tmp/hack-zope.location/bin:$PATH make html sphinx-build -b html -d _build/doctrees . _build/html ... build succeeded. Build finished. The HTML pages are in _build/html. You can also test the code snippets in the documentation: .. code-block:: sh $ PATH=/tmp/hack-zope.location/bin:$PATH make doctest sphinx-build -b doctest -d _build/doctrees . _build/doctest ... running tests... ... Doctest summary =============== 187 tests 0 failures in tests 0 failures in setup code 0 failures in cleanup code build succeeded. Testing of doctests in the sources finished, look at the results in _build/doctest/output.txt. Using :mod:`zc.buildout` ######################## Setting up the buildout ----------------------- :mod:`zope.location` ships with its own :file:`buildout.cfg` file and :file:`bootstrap.py` for setting up a development buildout: .. code-block:: sh $ /path/to/python2.7 bootstrap.py ... Generated script '.../bin/buildout' $ bin/buildout Develop: '/home/jrandom/projects/Zope/zope.location/.' ... Got coverage 3.7.1 Running the tests ----------------- You can now run the tests: .. code-block:: sh $ bin/test --all Running zope.testing.testrunner.layer.UnitTests tests: Set up zope.testing.testrunner.layer.UnitTests in 0.000 seconds. Ran 79 tests with 0 failures and 0 errors in 0.000 seconds. Tearing down left over layers: Tear down zope.testing.testrunner.layer.UnitTests in 0.000 seconds. Using :mod:`tox` ################ Running Tests on Multiple Python Versions ----------------------------------------- `tox `_ is a Python-based test automation tool designed to run tests against multiple Python versions. It creates a ``virtualenv`` for each configured version, installs the current package and configured dependencies into each ``virtualenv``, and then runs the configured commands. :mod:`zope.location` configures the following :mod:`tox` environments via its ``tox.ini`` file: - The ``py26``, ``py27``, ``py33``, ``py34``, and ``pypy`` environments builds a ``virtualenv`` with ``pypy``, installs :mod:`zope.location` and dependencies, and runs the tests via ``python setup.py test -q``. - The ``coverage`` environment builds a ``virtualenv`` with ``python2.6``, installs :mod:`zope.location`, installs :mod:`nose` and :mod:`coverage`, and runs ``nosetests`` with statement coverage. - The ``docs`` environment builds a virtualenv with ``python2.6``, installs :mod:`zope.location`, installs ``Sphinx`` and dependencies, and then builds the docs and exercises the doctest snippets. This example requires that you have a working ``python2.6`` on your path, as well as installing ``tox``: .. code-block:: sh $ tox -e py26 GLOB sdist-make: /home/jrandom/projects/Zope/Z3/zope.location/setup.py py26 create: /home/jrandom/projects/Zope/Z3/zope.location/.tox/py26 py26 installdeps: zope.configuration, zope.copy, zope.interface, zope.proxy, zope.schema py26 inst: /home/jrandom/projects/Zope/Z3/zope.location/.tox/dist/zope.location-4.0.4.dev0.zip py26 runtests: PYTHONHASHSEED='3489368878' py26 runtests: commands[0] | python setup.py test -q running test ... ................................................................................... ---------------------------------------------------------------------- Ran 83 tests in 0.066s OK ___________________________________ summary ____________________________________ py26: commands succeeded congratulations :) Running ``tox`` with no arguments runs all the configured environments, including building the docs and testing their snippets: .. code-block:: sh $ tox GLOB sdist-make: .../zope.location/setup.py py26 sdist-reinst: .../zope.location/.tox/dist/zope.location-4.0.2dev.zip ... Doctest summary =============== 187 tests 0 failures in tests 0 failures in setup code 0 failures in cleanup code build succeeded. ___________________________________ summary ____________________________________ py26: commands succeeded py27: commands succeeded py32: commands succeeded py33: commands succeeded py34: commands succeeded pypy: commands succeeded coverage: commands succeeded docs: commands succeeded congratulations :) Contributing to :mod:`zope.location` #################################### Submitting a Bug Report ----------------------- :mod:`zope.location` tracks its bugs on Github: https://github.com/zopefoundation/zope.location/issues Please submit bug reports and feature requests there. Sharing Your Changes -------------------- .. note:: Please ensure that all tests are passing before you submit your code. If possible, your submission should include new tests for new features or bug fixes, although it is possible that you may have tested your new code by updating existing tests. If have made a change you would like to share, the best route is to fork the Githb repository, check out your fork, make your changes on a branch in your fork, and push it. You can then submit a pull request from your branch: https://github.com/zopefoundation/zope.location/pulls If you branched the code from Launchpad using Bazaar, you have another option: you can "push" your branch to Launchpad: .. code-block:: sh $ bzr push lp:~jrandom/zope.location/cool_feature After pushing your branch, you can link it to a bug report on Github, or request that the maintainers merge your branch using the Launchpad "merge request" feature. zope.location-4.2/docs/_static/0000755000076500000240000000000013357130166016411 5ustar macstaff00000000000000zope.location-4.2/docs/_static/.gitignore0000644000076500000240000000000013357130166020367 0ustar macstaff00000000000000zope.location-4.2/docs/make.bat0000644000076500000240000001176413357130166016401 0ustar macstaff00000000000000@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.2/docs/narr.rst0000644000076500000240000001113513357130166016460 0ustar macstaff00000000000000Using :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__ = b'foo' >>> a.location = loc Traceback (most recent call last): ... SchemaNotCorrectlyImplemented: ([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) >>> next(iter) is o3 True >>> next(iter) is o2 True >>> next(iter) is o1 True >>> next(iter) 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.2/docs/api.rst0000644000076500000240000002513413357130166016273 0ustar macstaff00000000000000: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) >>> print(LocationPhysicallyLocatable(root).getPath()) / >>> o1 = Location(); o1.__parent__ = root; o1.__name__ = 'o1' >>> print(LocationPhysicallyLocatable(o1).getPath()) /o1 >>> o2 = Location(); o2.__parent__ = o1; o2.__name__ = u'o2' >>> print(LocationPhysicallyLocatable(o2).getPath()) /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' >>> print(LocationPhysicallyLocatable(o1).getName()) 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() >>> print(RootPhysicallyLocatable(o1).getPath()) / .. 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'' True .. 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.2/setup.py0000644000076500000240000000651013357130166015547 0ustar macstaff00000000000000############################################################################## # # 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): with open(os.path.join(os.path.dirname(__file__), *rnames)) as f: return f.read() ZCML_REQUIRES = [ 'zope.configuration', ] COMPONENT_REQUIRES = [ 'zope.component >= 4.0.1', ] TESTS_REQUIRE = ZCML_REQUIRES + COMPONENT_REQUIRES + [ 'zope.copy >= 4.0', 'zope.testrunner', ] DOCS_REQUIRE = [ 'Sphinx', 'repoze.sphinx.autointerface', ] + ZCML_REQUIRES + COMPONENT_REQUIRES # doctest snippets need these setup(name='zope.location', version='4.2', 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.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', '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://github.com/zopefoundation/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': ZCML_REQUIRES, 'component': COMPONENT_REQUIRES, 'test': TESTS_REQUIRE, 'docs': DOCS_REQUIRE, }, test_suite='zope.location.tests', include_package_data=True, zip_safe=False, ) zope.location-4.2/.gitignore0000644000076500000240000000020713357130166016022 0ustar macstaff00000000000000*.pyc __pycache__ *.egg-info .installed.cfg bin develop-eggs eggs parts docs/_build .tox .coverage nosetests.xml coverage.xml htmlcov/ zope.location-4.2/tox.ini0000644000076500000240000000170713357130166015353 0ustar macstaff00000000000000[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 # py27,jython,pypy,coverage py27,py34,py35,py36,py37,pypy,pypy3,coverage [testenv] commands = zope-testrunner --test-path=src [] sphinx-build -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest deps = .[test,docs] [testenv:jython] commands = jython setup.py test -q [testenv:coverage] usedevelop = true basepython = python3.7 commands = coverage run -m zope.testrunner --test-path=src coverage run -a -m sphinx -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest coverage report deps = {[testenv]deps} coverage [testenv:docs] basepython = python3.7 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 = .[docs] zope.location-4.2/setup.cfg0000644000076500000240000000041613357130166015655 0ustar macstaff00000000000000[nosetests] nocapture = 1 cover-package = zope.location cover-erase = 1 with-doctest = 0 where = src [aliases] dev = develop easy_install zope.location[testing] docs = easy_install zope.location[docs] [bdist_wheel] universal = 1 [egg_info] tag_build = tag_date = 0 zope.location-4.2/README.rst0000644000076500000240000000231413357130166015522 0ustar macstaff00000000000000=================== ``zope.location`` =================== .. image:: https://img.shields.io/pypi/v/zope.location.svg :target: https://pypi.python.org/pypi/zope.location/ :alt: Latest release .. image:: https://img.shields.io/pypi/pyversions/zope.location.svg :target: https://pypi.org/project/zope.location/ :alt: Supported Python versions .. image:: https://travis-ci.org/zopefoundation/zope.location.svg?branch=master :target: https://travis-ci.org/zopefoundation/zope.location .. image:: https://coveralls.io/repos/github/zopefoundation/zope.location/badge.svg?branch=master :target: https://coveralls.io/github/zopefoundation/zope.location?branch=master .. image:: https://readthedocs.org/projects/zopelocation/badge/?version=latest :target: http://zopelocation.readthedocs.org/en/latest/ :alt: Documentation Status In Zope3, "locations" are special objects that have a structural location, indicated with ``__name__`` and ``__parent__`` attributes. See `zope.container `_ for a useful extension of this concept to "containers." Documentation is hosted at https://zopelocation.readthedocs.io/en/latest/ zope.location-4.2/LICENSE.txt0000644000076500000240000000402613357130166015660 0ustar macstaff00000000000000Zope 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.2/CHANGES.rst0000644000076500000240000001416713357130166015646 0ustar macstaff00000000000000========= Changes ========= 4.2 (2018-10-09) ================ - Add support for Python 3.7. 4.1.0 (2017-08-03) ================== - Drop support for Python 2.6, 3.2 and 3.3. - Add a page to the docs on hacking ``zope.location``. - Note additional documentation dependencies. - Add support for Python 3.5 and 3.6. - Remove internal ``_compat`` implementation module. 4.0.3 (2014-03-19) ================== - Add Python 3.4 support. - Update ``boostrap.py`` to version 2.2. 4.0.2 (2013-03-11) ================== - Change 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) ================== - Add Python 3.3 support. 4.0.0 (2012-06-07) ================== - Remove 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``). - Add Python 3.2 support. - Make ``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. - Add support for PyPy. - Add support for continuous integration using ``tox`` and ``jenkins``. - Bring unit test coverage to 100%. - Add Sphinx documentation: moved doctest examples to API reference. - Add 'setup.py docs' alias (installs ``Sphinx`` and dependencies). - Add 'setup.py dev' alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Replace deprecated ``zope.component.adapts`` usage with equivalent ``zope.component.adapter`` decorator. - Replace deprecated ``zope.interface.implements`` usage with equivalent ``zope.interface.implementer`` decorator. - Drop support for Python 2.4 and 2.5. 3.9.1 (2011-08-22) ================== - Add zcml extra as well as a test for configure.zcml. 3.9.0 (2009-12-29) ================== - Move LocationCopyHook related tests to zope.copy and remove a test dependency on that package. 3.8.2 (2009-12-23) ================== - Fix a typo in the configure.zcml. 3.8.1 (2009-12-23) ================== - Remove 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) ================== - Adjust to testing output caused by new zope.schema. 3.7.1 (2009-11-18) ================== - Move 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) ================== - Add getParent() to ILocationInfo and moved the actual implementation here from zope.traversal.api, analogous to getParents(). - Actually remove deprecated PathPersistent class from zope.location.pickling. - Move 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: deprecate 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. - Remove 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.2/.travis.yml0000644000076500000240000000103313357130166016141 0ustar macstaff00000000000000language: python sudo: false python: - 2.7 - 3.4 - 3.5 - 3.6 - pypy - pypy3 matrix: include: - python: "3.7" dist: xenial sudo: true install: - pip install -U pip setuptools - pip install -U coverage coveralls - pip install -U -e .[test,docs] script: - coverage run -m zope.testrunner --test-path=src - coverage run -a -m sphinx -b doctest -d docs/_build/doctrees docs docs/_build/doctest after_success: - coveralls notifications: email: false cache: pip zope.location-4.2/src/0000755000076500000240000000000013357130166014622 5ustar macstaff00000000000000zope.location-4.2/src/zope.location.egg-info/0000755000076500000240000000000013357130166021100 5ustar macstaff00000000000000zope.location-4.2/src/zope.location.egg-info/PKG-INFO0000644000076500000240000002477113357130166022210 0ustar macstaff00000000000000Metadata-Version: 2.1 Name: zope.location Version: 4.2 Summary: Zope Location Home-page: http://github.com/zopefoundation/zope.location/ Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Description: =================== ``zope.location`` =================== .. image:: https://img.shields.io/pypi/v/zope.location.svg :target: https://pypi.python.org/pypi/zope.location/ :alt: Latest release .. image:: https://img.shields.io/pypi/pyversions/zope.location.svg :target: https://pypi.org/project/zope.location/ :alt: Supported Python versions .. image:: https://travis-ci.org/zopefoundation/zope.location.svg?branch=master :target: https://travis-ci.org/zopefoundation/zope.location .. image:: https://coveralls.io/repos/github/zopefoundation/zope.location/badge.svg?branch=master :target: https://coveralls.io/github/zopefoundation/zope.location?branch=master .. image:: https://readthedocs.org/projects/zopelocation/badge/?version=latest :target: http://zopelocation.readthedocs.org/en/latest/ :alt: Documentation Status In Zope3, "locations" are special objects that have a structural location, indicated with ``__name__`` and ``__parent__`` attributes. See `zope.container `_ for a useful extension of this concept to "containers." Documentation is hosted at https://zopelocation.readthedocs.io/en/latest/ ========= Changes ========= 4.2 (2018-10-09) ================ - Add support for Python 3.7. 4.1.0 (2017-08-03) ================== - Drop support for Python 2.6, 3.2 and 3.3. - Add a page to the docs on hacking ``zope.location``. - Note additional documentation dependencies. - Add support for Python 3.5 and 3.6. - Remove internal ``_compat`` implementation module. 4.0.3 (2014-03-19) ================== - Add Python 3.4 support. - Update ``boostrap.py`` to version 2.2. 4.0.2 (2013-03-11) ================== - Change 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) ================== - Add Python 3.3 support. 4.0.0 (2012-06-07) ================== - Remove 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``). - Add Python 3.2 support. - Make ``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. - Add support for PyPy. - Add support for continuous integration using ``tox`` and ``jenkins``. - Bring unit test coverage to 100%. - Add Sphinx documentation: moved doctest examples to API reference. - Add 'setup.py docs' alias (installs ``Sphinx`` and dependencies). - Add 'setup.py dev' alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Replace deprecated ``zope.component.adapts`` usage with equivalent ``zope.component.adapter`` decorator. - Replace deprecated ``zope.interface.implements`` usage with equivalent ``zope.interface.implementer`` decorator. - Drop support for Python 2.4 and 2.5. 3.9.1 (2011-08-22) ================== - Add zcml extra as well as a test for configure.zcml. 3.9.0 (2009-12-29) ================== - Move LocationCopyHook related tests to zope.copy and remove a test dependency on that package. 3.8.2 (2009-12-23) ================== - Fix a typo in the configure.zcml. 3.8.1 (2009-12-23) ================== - Remove 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) ================== - Adjust to testing output caused by new zope.schema. 3.7.1 (2009-11-18) ================== - Move 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) ================== - Add getParent() to ILocationInfo and moved the actual implementation here from zope.traversal.api, analogous to getParents(). - Actually remove deprecated PathPersistent class from zope.location.pickling. - Move 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: deprecate 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. - Remove 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.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 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 Provides-Extra: test Provides-Extra: docs Provides-Extra: component Provides-Extra: zcml zope.location-4.2/src/zope.location.egg-info/not-zip-safe0000644000076500000240000000000113357130166023326 0ustar macstaff00000000000000 zope.location-4.2/src/zope.location.egg-info/namespace_packages.txt0000644000076500000240000000000513357130166025426 0ustar macstaff00000000000000zope zope.location-4.2/src/zope.location.egg-info/SOURCES.txt0000644000076500000240000000173113357130166022766 0ustar macstaff00000000000000.coveragerc .gitignore .travis.yml CHANGES.rst COPYRIGHT.txt LICENSE.txt MANIFEST.in README.rst bootstrap.py buildout.cfg rtd.txt setup.cfg setup.py tox.ini docs/Makefile docs/api.rst docs/conf.py docs/hacking.rst docs/index.rst docs/make.bat docs/narr.rst docs/_static/.gitignore 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/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.2/src/zope.location.egg-info/requires.txt0000644000076500000240000000045013357130166023477 0ustar macstaff00000000000000setuptools zope.interface>=4.0.2 zope.schema>=4.2.2 zope.proxy>=4.0.1 [component] zope.component>=4.0.1 [docs] Sphinx repoze.sphinx.autointerface zope.configuration zope.component>=4.0.1 [test] zope.configuration zope.component>=4.0.1 zope.copy>=4.0 zope.testrunner [zcml] zope.configuration zope.location-4.2/src/zope.location.egg-info/top_level.txt0000644000076500000240000000000513357130166023625 0ustar macstaff00000000000000zope zope.location-4.2/src/zope.location.egg-info/dependency_links.txt0000644000076500000240000000000113357130166025146 0ustar macstaff00000000000000 zope.location-4.2/src/zope/0000755000076500000240000000000013357130166015577 5ustar macstaff00000000000000zope.location-4.2/src/zope/location/0000755000076500000240000000000013357130166017407 5ustar macstaff00000000000000zope.location-4.2/src/zope/location/interfaces.py0000644000076500000240000000767213357130166022120 0ustar macstaff00000000000000############################################################################## # # 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 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 " u"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 # backward-compatibility try: from zope.component.interfaces import ISite except ImportError: # pragma: no cover class ISite(Interface): pass zope.location-4.2/src/zope/location/configure.zcml0000644000076500000240000000124713357130166022263 0ustar macstaff00000000000000 zope.location-4.2/src/zope/location/traversing.py0000644000076500000240000001063713357130166022154 0ustar macstaff00000000000000############################################################################## # # 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 @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) 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.2/src/zope/location/tests/0000755000076500000240000000000013357130166020551 5ustar macstaff00000000000000zope.location-4.2/src/zope/location/tests/__init__.py0000644000076500000240000000001113357130166022652 0ustar macstaff00000000000000#package zope.location-4.2/src/zope/location/tests/test_configure.py0000644000076500000240000000261613357130166024150 0ustar macstaff00000000000000############################################################################## # # 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): import zope.component # no registrations made if not present ADAPTERS_REGISTERED = 4 from zope.configuration.xmlconfig import _clearContext from zope.configuration.xmlconfig import _getContext from zope.configuration.xmlconfig import XMLConfig 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.defaultTestLoader.loadTestsFromName(__name__) zope.location-4.2/src/zope/location/tests/test_pickling.py0000644000076500000240000000412313357130166023762 0ustar macstaff00000000000000############################################################################## # # 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 import zope.copy 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.defaultTestLoader.loadTestsFromName(__name__) zope.location-4.2/src/zope/location/tests/test_location.py0000644000076500000240000003303213357130166023773 0ustar macstaff00000000000000############################################################################## # # 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: self.assertIs(name, _MARKER) return self._getTargetClass()(obj) self.assertIsNot(name, _MARKER) 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 Context(object): """CONTEXT""" proxy = self._makeOne(Context()) self.assertEqual(proxy.__doc__, 'CONTEXT') def test___doc___from_target_instance(self): klass = self._getTargetClass() 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): raise AssertionError("This is not called") 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: # pragma: no cover 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.defaultTestLoader.loadTestsFromName(__name__) zope.location-4.2/src/zope/location/tests/test_traversing.py0000644000076500000240000002412213357130166024347 0ustar macstaff00000000000000############################################################################## # # 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.2/src/zope/location/__init__.py0000644000076500000240000000154413357130166021524 0ustar macstaff00000000000000############################################################################## # # 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.2/src/zope/location/location.py0000644000076500000240000000722313357130166021575 0ustar macstaff00000000000000############################################################################## # # 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.2/src/zope/location/pickling.py0000644000076500000240000000263713357130166021571 0ustar macstaff00000000000000############################################################################## # # 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.2/src/zope/__init__.py0000644000076500000240000000011313357130166017703 0ustar macstaff00000000000000__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover