zope.location-3.9.1/0000755000177100020040000000000011624507356015445 5ustar menesismenesis00000000000000zope.location-3.9.1/CHANGES.txt0000644000177100020040000001006211624507270017250 0ustar menesismenesis00000000000000======= CHANGES ======= 3.9.1 (2011-08-22) ------------------ - Added zcml extra as well as a test for configure.zcml. 3.9.0 (2009-12-29) ------------------ - Moved LocationCopyHook related tests to zope.copy and remove a test dependency on that package. 3.8.2 (2009-12-23) ------------------ - Fixed a typo in the configure.zcml. 3.8.1 (2009-12-23) ------------------ - Removed dependency on zope.copy: the LocationCopyHook adapter is registered only if zope.copy is available. - Use the standard Python doctest module instead of zope.testing.doctest, which has been deprecated. 3.8.0 (2009-12-22) ------------------ - Adjusted to testing output caused by new zope.schema. 3.7.1 (2009-11-18) ------------------ - Moved the IPossibleSite and ISite interfaces to zope.component as they are dealing with zope.component's concept of a site, but not with location. 3.7.0 (2009-09-29) ------------------ - Added getParent() to ILocationInfo and moved the actual implementation here from zope.traversal.api, analogous to getParents(). - Actually removed deprecated PathPersistent class from zope.location.pickling. - Moved ITraverser back to zope.traversing where it belongs conceptually. The interface had been moved to zope.location to invert the package interdependency but is no longer used here. 3.6.0 (2009-08-27) ------------------ - New feature release: deprecated locationCopy, CopyPersistent and PathPersistent from zope.location.pickling. These changes were already part of the 3.5.3 release, which was erroneously numbered as a bugfix relese. - Removed dependency on zope.deferredimport, directly import deprecated modules without using it. 3.5.5 (2009-08-15) ------------------ - Add zope.deferredimport as a dependency as it's used directly by zope.location.pickling. 3.5.4 (2009-05-17) ------------------ - Add ``IContained`` interface to ``zope.location.interfaces`` module. This interface was moved from ``zope.container`` (after ``zope.container`` 3.8.2); consumers of ``IContained`` may now depend on zope.location rather than zope.container to reduce dependency cycles. 3.5.3 (2009-02-09) ------------------ - Use new zope.copy package for implementing location copying. Thus there's changes in the ``zope.locaton.pickling`` module: * The ``locationCopy`` and ``CopyPersistent`` was removed in prefer to their equivalents in zope.copy. Deprecated backward-compatibility imports provided. * The module now provides a ``zope.copy.interfaces.ICopyHook`` adapter for ``ILocation`` objects that replaces the old CopyPersistent functionality of checking for the need to clone objects based on their location. 3.5.2 (2009-02-04) ------------------ - Split RootPhysicallyLocatable adapter back from LocationPhysicallyLocatable, because the IRoot object may not always provide ILocation and the code for the root object is also simplier. It's basically a copy of the RootPhysicallyLocatable adapter from zope.traversing version 3.5.0 and below with ``getParents`` method added (returns an empty list). 3.5.1 (2009-02-02) ------------------ - Improve test coverage. - The new ``getParents`` method was extracted from ``zope.traversing`` and added to ILocationInfo interface in the previous release. Custom ILocationInfo implementations should make sure they have this method as well. That method is already used in ``zope.traversing.api.getParents`` function. - Make ``getName`` of LocationPhysicallyLocatable always return empty string for the IRoot object, like RootPhysicallyLocatable from ``zope.traversing`` did. So, now LocationPhysicallyLocatable is fully compatible with RootPhysicallyLocatable, making the latter one obsolete. - Change package mailing list address to zope-dev at zope.org instead of retired zope3-dev at zope.org. 3.5.0 (2009-01-31) ------------------ - Reverse the dependency between zope.location and zope.traversing. This also causes the dependency to various other packages go away. 3.4.0 (2007-10-02) ------------------ - Initial release independent of the main Zope tree. zope.location-3.9.1/PKG-INFO0000644000177100020040000002736111624507356016553 0ustar menesismenesis00000000000000Metadata-Version: 1.0 Name: zope.location Version: 3.9.1 Summary: Zope Location Home-page: http://pypi.python.org/pypi/zope.location/ Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Description: Zope Location ============= Overview ======== In Zope3, location are special objects that has a structural location. Detailed Documentation ====================== ======== Location ======== Location Base Class ------------------- The `Location` base class is a stupid mix-in that defines `__parent__` and `__name__` attributes. Usage within an Object field: >>> from zope.interface import implements, 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) >>> class A(object): ... implements(IA) ... location = FieldProperty(IA['location']) >>> a = A() >>> a.location = Location() >>> loc = Location(); loc.__name__ = u'foo' >>> a.location = loc >>> loc = Location(); loc.__name__ = None >>> a.location = loc >>> loc = Location(); loc.__name__ = 'foo' >>> a.location = loc Traceback (most recent call last): ... WrongContainedType: ([WrongType('foo', , '__name__')], 'location') The `inside` Function --------------------- The `inside` function tells if l1 is inside l2. L1 is inside l2 if l2 is an ancestor of l1. >>> 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 LocationProxy ------------- The LocationProxy is a non-picklable proxy that can be put around objects that don't implement `ILocation`. >>> 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: >>> p.__doc__ == l.__doc__ True If we get a "located class" somehow, its doc string well be available through proxy as well: >>> class LocalClass(object): ... """This is class that can be located""" >>> p = LocationProxy(LocalClass) >>> p.__doc__ == LocalClass.__doc__ True LocationInterator ----------------- This function allows us to iterate over object and all its parents. >>> from zope.location.location import LocationIterator >>> o1 = Location() >>> o2 = Location() >>> o3 = Location() >>> o3.__parent__ = o2 >>> o2.__parent__ = o1 >>> iter = LocationIterator(o3) >>> iter.next() is o3 True >>> iter.next() is o2 True >>> iter.next() is o1 True >>> iter.next() Traceback (most recent call last): ... StopIteration The `located` function ---------------------- `located` locates an object in another and returns it: >>> 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: >>> 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: >>> 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: >>> 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 ======= CHANGES ======= 3.9.1 (2011-08-22) ------------------ - Added zcml extra as well as a test for configure.zcml. 3.9.0 (2009-12-29) ------------------ - Moved LocationCopyHook related tests to zope.copy and remove a test dependency on that package. 3.8.2 (2009-12-23) ------------------ - Fixed a typo in the configure.zcml. 3.8.1 (2009-12-23) ------------------ - Removed dependency on zope.copy: the LocationCopyHook adapter is registered only if zope.copy is available. - Use the standard Python doctest module instead of zope.testing.doctest, which has been deprecated. 3.8.0 (2009-12-22) ------------------ - Adjusted to testing output caused by new zope.schema. 3.7.1 (2009-11-18) ------------------ - Moved the IPossibleSite and ISite interfaces to zope.component as they are dealing with zope.component's concept of a site, but not with location. 3.7.0 (2009-09-29) ------------------ - Added getParent() to ILocationInfo and moved the actual implementation here from zope.traversal.api, analogous to getParents(). - Actually removed deprecated PathPersistent class from zope.location.pickling. - Moved ITraverser back to zope.traversing where it belongs conceptually. The interface had been moved to zope.location to invert the package interdependency but is no longer used here. 3.6.0 (2009-08-27) ------------------ - New feature release: deprecated locationCopy, CopyPersistent and PathPersistent from zope.location.pickling. These changes were already part of the 3.5.3 release, which was erroneously numbered as a bugfix relese. - Removed dependency on zope.deferredimport, directly import deprecated modules without using it. 3.5.5 (2009-08-15) ------------------ - Add zope.deferredimport as a dependency as it's used directly by zope.location.pickling. 3.5.4 (2009-05-17) ------------------ - Add ``IContained`` interface to ``zope.location.interfaces`` module. This interface was moved from ``zope.container`` (after ``zope.container`` 3.8.2); consumers of ``IContained`` may now depend on zope.location rather than zope.container to reduce dependency cycles. 3.5.3 (2009-02-09) ------------------ - Use new zope.copy package for implementing location copying. Thus there's changes in the ``zope.locaton.pickling`` module: * The ``locationCopy`` and ``CopyPersistent`` was removed in prefer to their equivalents in zope.copy. Deprecated backward-compatibility imports provided. * The module now provides a ``zope.copy.interfaces.ICopyHook`` adapter for ``ILocation`` objects that replaces the old CopyPersistent functionality of checking for the need to clone objects based on their location. 3.5.2 (2009-02-04) ------------------ - Split RootPhysicallyLocatable adapter back from LocationPhysicallyLocatable, because the IRoot object may not always provide ILocation and the code for the root object is also simplier. It's basically a copy of the RootPhysicallyLocatable adapter from zope.traversing version 3.5.0 and below with ``getParents`` method added (returns an empty list). 3.5.1 (2009-02-02) ------------------ - Improve test coverage. - The new ``getParents`` method was extracted from ``zope.traversing`` and added to ILocationInfo interface in the previous release. Custom ILocationInfo implementations should make sure they have this method as well. That method is already used in ``zope.traversing.api.getParents`` function. - Make ``getName`` of LocationPhysicallyLocatable always return empty string for the IRoot object, like RootPhysicallyLocatable from ``zope.traversing`` did. So, now LocationPhysicallyLocatable is fully compatible with RootPhysicallyLocatable, making the latter one obsolete. - Change package mailing list address to zope-dev at zope.org instead of retired zope3-dev at zope.org. 3.5.0 (2009-01-31) ------------------ - Reverse the dependency between zope.location and zope.traversing. This also causes the dependency to various other packages go away. 3.4.0 (2007-10-02) ------------------ - Initial release independent of the main Zope tree. Keywords: zope location structural Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License Classifier: Programming Language :: Python Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Topic :: Internet :: WWW/HTTP Classifier: Framework :: Zope3 zope.location-3.9.1/README.txt0000644000177100020040000000016711624507270017142 0ustar menesismenesis00000000000000Zope Location ============= Overview ======== In Zope3, location are special objects that has a structural location. zope.location-3.9.1/setup.py0000644000177100020040000000517011624507270017155 0ustar menesismenesis00000000000000############################################################################## # # Copyright (c) 2006 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## # This package is developed by the Zope Toolkit project, documented here: # http://docs.zope.org/zopetoolkit # When developing and releasing this package, please follow the documented # Zope Toolkit policies as described by this documentation. ############################################################################## """Setup for zope.location package """ import os from setuptools import setup, find_packages def read(*rnames): text = open(os.path.join(os.path.dirname(__file__), *rnames)).read() return text setup(name='zope.location', version='3.9.1', author='Zope Corporation and Contributors', author_email='zope-dev@zope.org', description='Zope Location', long_description=( read('README.txt') + '\n\n' + 'Detailed Documentation\n' + '======================' + '\n\n' + read('src', 'zope', 'location', 'location.txt') + '\n\n' + read('CHANGES.txt') ), 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', 'Natural Language :: English', 'Operating System :: OS Independent', 'Topic :: Internet :: WWW/HTTP', 'Framework :: Zope3'], url='http://pypi.python.org/pypi/zope.location/', packages=find_packages('src'), package_dir = {'': 'src'}, namespace_packages=['zope',], install_requires=['setuptools', 'zope.interface', 'zope.schema>=3.6', 'zope.component>=3.8', 'zope.proxy>3.3', ], extras_require={ 'zcml': ['zope.configuration'], }, include_package_data = True, zip_safe = False, ) zope.location-3.9.1/COPYRIGHT.txt0000644000177100020040000000004011624507270017543 0ustar menesismenesis00000000000000Zope Foundation and Contributorszope.location-3.9.1/LICENSE.txt0000644000177100020040000000402611624507270017265 0ustar menesismenesis00000000000000Zope 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-3.9.1/bootstrap.py0000644000177100020040000002352211624507270020033 0ustar menesismenesis00000000000000############################################################################## # # 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, shutil, sys, tempfile, textwrap, urllib, urllib2, subprocess from optparse import OptionParser if sys.platform == 'win32': def quote(c): if ' ' in c: return '"%s"' % c # work around spawn lamosity on windows else: return c else: quote = str # See zc.buildout.easy_install._has_broken_dash_S for motivation and comments. stdout, stderr = subprocess.Popen( [sys.executable, '-Sc', 'try:\n' ' import ConfigParser\n' 'except ImportError:\n' ' print 1\n' 'else:\n' ' print 0\n'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() has_broken_dash_S = bool(int(stdout.strip())) # In order to be more robust in the face of system Pythons, we want to # run without site-packages loaded. This is somewhat tricky, in # particular because Python 2.6's distutils imports site, so starting # with the -S flag is not sufficient. However, we'll start with that: if not has_broken_dash_S and 'site' in sys.modules: # We will restart with python -S. args = sys.argv[:] args[0:0] = [sys.executable, '-S'] args = map(quote, args) os.execv(sys.executable, args) # Now we are running with -S. We'll get the clean sys.path, import site # because distutils will do it later, and then reset the path and clean # out any namespace packages from site-packages that might have been # loaded by .pth files. clean_path = sys.path[:] import site sys.path[:] = clean_path for k, v in sys.modules.items(): if k in ('setuptools', 'pkg_resources') or ( hasattr(v, '__path__') and len(v.__path__)==1 and not os.path.exists(os.path.join(v.__path__[0],'__init__.py'))): # This is a namespace package. Remove it. sys.modules.pop(k) is_jython = sys.platform.startswith('java') setuptools_source = 'http://peak.telecommunity.com/dist/ez_setup.py' distribute_source = 'http://python-distribute.org/distribute_setup.py' # parsing arguments def normalize_to_url(option, opt_str, value, parser): if value: if '://' not in value: # It doesn't smell like a URL. value = 'file://%s' % ( urllib.pathname2url( os.path.abspath(os.path.expanduser(value))),) if opt_str == '--download-base' and not value.endswith('/'): # Download base needs a trailing slash to make the world happy. value += '/' else: value = None name = opt_str[2:].replace('-', '_') setattr(parser.values, name, value) 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 --setup-source and --download-base to point to local resources, you can keep this script from going over the network. ''' parser = OptionParser(usage=usage) parser.add_option("-v", "--version", dest="version", help="use a specific zc.buildout version") parser.add_option("-d", "--distribute", action="store_true", dest="use_distribute", default=False, help="Use Distribute rather than Setuptools.") parser.add_option("--setup-source", action="callback", dest="setup_source", callback=normalize_to_url, nargs=1, type="string", help=("Specify a URL or file location for the setup file. " "If you use Setuptools, this will default to " + setuptools_source + "; if you use Distribute, this " "will default to " + distribute_source +".")) parser.add_option("--download-base", action="callback", dest="download_base", callback=normalize_to_url, nargs=1, type="string", help=("Specify a URL or directory for downloading " "zc.buildout and either Setuptools or Distribute. " "Defaults to PyPI.")) parser.add_option("--eggs", help=("Specify a directory for storing eggs. Defaults to " "a temporary directory that is deleted when the " "bootstrap script completes.")) 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", None, action="store", dest="config_file", help=("Specify the path to the buildout configuration " "file to be used.")) options, args = parser.parse_args() # if -c was provided, we push it back into args for buildout's main function if options.config_file is not None: args += ['-c', options.config_file] if options.eggs: eggs_dir = os.path.abspath(os.path.expanduser(options.eggs)) else: eggs_dir = tempfile.mkdtemp() if options.setup_source is None: if options.use_distribute: options.setup_source = distribute_source else: options.setup_source = setuptools_source if options.accept_buildout_test_releases: args.append('buildout:accept-buildout-test-releases=true') args.append('bootstrap') try: import pkg_resources import setuptools # A flag. Sometimes pkg_resources is installed alone. if not hasattr(pkg_resources, '_distribute'): raise ImportError except ImportError: ez_code = urllib2.urlopen( options.setup_source).read().replace('\r\n', '\n') ez = {} exec ez_code in ez setup_args = dict(to_dir=eggs_dir, download_delay=0) if options.download_base: setup_args['download_base'] = options.download_base if options.use_distribute: setup_args['no_fake'] = True ez['use_setuptools'](**setup_args) if 'pkg_resources' in sys.modules: reload(sys.modules['pkg_resources']) import pkg_resources # This does not (always?) update the default working set. We will # do it. for path in sys.path: if path not in pkg_resources.working_set.entries: pkg_resources.working_set.add_entry(path) cmd = [quote(sys.executable), '-c', quote('from setuptools.command.easy_install import main; main()'), '-mqNxd', quote(eggs_dir)] if not has_broken_dash_S: cmd.insert(1, '-S') find_links = options.download_base if not find_links: find_links = os.environ.get('bootstrap-testing-find-links') if find_links: cmd.extend(['-f', quote(find_links)]) if options.use_distribute: setup_requirement = 'distribute' else: setup_requirement = 'setuptools' ws = pkg_resources.working_set setup_requirement_path = ws.find( pkg_resources.Requirement.parse(setup_requirement)).location env = dict( os.environ, PYTHONPATH=setup_requirement_path) requirement = 'zc.buildout' version = options.version if version is None and not options.accept_buildout_test_releases: # Figure out the most recent final version of zc.buildout. import setuptools.package_index _final_parts = '*final-', '*final' def _final_version(parsed_version): for part in parsed_version: if (part[:1] == '*') and (part not in _final_parts): return False return True index = setuptools.package_index.PackageIndex( search_path=[setup_requirement_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) if is_jython: import subprocess exitcode = subprocess.Popen(cmd, env=env).wait() else: # Windows prefers this, apparently; otherwise we would prefer subprocess exitcode = os.spawnle(*([os.P_WAIT, sys.executable] + cmd + [env])) if exitcode != 0: sys.stdout.flush() sys.stderr.flush() print ("An error occurred when trying to install zc.buildout. " "Look above this message for any errors that " "were output by easy_install.") sys.exit(exitcode) ws.add_entry(eggs_dir) ws.require(requirement) import zc.buildout.buildout zc.buildout.buildout.main(args) if not options.eggs: # clean up temporary egg directory shutil.rmtree(eggs_dir) zope.location-3.9.1/setup.cfg0000644000177100020040000000007311624507356017266 0ustar menesismenesis00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 zope.location-3.9.1/src/0000755000177100020040000000000011624507356016234 5ustar menesismenesis00000000000000zope.location-3.9.1/src/zope/0000755000177100020040000000000011624507356017211 5ustar menesismenesis00000000000000zope.location-3.9.1/src/zope/__init__.py0000644000177100020040000000007011624507270021312 0ustar menesismenesis00000000000000__import__('pkg_resources').declare_namespace(__name__) zope.location-3.9.1/src/zope/location/0000755000177100020040000000000011624507356021021 5ustar menesismenesis00000000000000zope.location-3.9.1/src/zope/location/__init__.py0000644000177100020040000000154411624507270023131 0ustar menesismenesis00000000000000############################################################################## # # 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-3.9.1/src/zope/location/interfaces.py0000644000177100020040000000737111624507270023521 0ustar menesismenesis00000000000000############################################################################## # # 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' import zope.interface import zope.schema # BBB from zope.component.interfaces import IPossibleSite, ISite class ILocation(zope.interface.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__ = zope.interface.Attribute("The parent in the location hierarchy.") __name__ = zope.schema.TextLine( title=u"The name within the parent", description=u"The object can be looked up from the parent's " "sublocations using this name.", required=False, default=None) # The IContained interface was moved from zope.container to here in # zope.container 3.8.2 to break dependency cycles. It is not actually # used within this package, but is depended upon by external # consumers. class IContained(ILocation): """Objects contained in containers.""" class ILocationInfo(zope.interface.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(zope.interface.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(zope.interface.Interface): """Marker interface to designate root objects within a location hierarchy. """ class LocationError(KeyError, LookupError): """There is no object for a given location.""" zope.location-3.9.1/src/zope/location/traversing.py0000644000177100020040000002650411624507270023561 0ustar menesismenesis00000000000000############################################################################## # # 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' import zope.component import zope.component.interfaces import zope.interface from zope.location.interfaces import ILocationInfo from zope.location.interfaces import ILocation, IRoot from zope.location.location import Location class LocationPhysicallyLocatable(object): """Provide location information for location objects >>> from zope.interface.verify import verifyObject >>> info = LocationPhysicallyLocatable(Location()) >>> verifyObject(ILocationInfo, info) True """ zope.component.adapts(ILocation) zope.interface.implements(ILocationInfo) def __init__(self, context): self.context = context def getRoot(self): """Get the root location for a location. See ILocationInfo The root location is a location that contains the given location and that implements IContainmentRoot. >>> root = Location() >>> zope.interface.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: >>> 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: >>> o1.__parent__ = o2 >>> LocationPhysicallyLocatable(o1).getRoot() Traceback (most recent call last): ... TypeError: Maximum location depth exceeded, """ \ """probably due to a a location cycle. """ 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): """Get the path of a location. See ILocationInfo This is an "absolute path", rooted at a root object. >>> root = Location() >>> zope.interface.directlyProvides(root, IRoot) >>> LocationPhysicallyLocatable(root).getPath() u'/' >>> o1 = Location(); o1.__parent__ = root; o1.__name__ = 'o1' >>> LocationPhysicallyLocatable(o1).getPath() u'/o1' >>> o2 = Location(); o2.__parent__ = o1; o2.__name__ = u'o2' >>> LocationPhysicallyLocatable(o2).getPath() u'/o1/o2' It is an error to get the path of a rootless location: >>> 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: >>> o1.__parent__ = o2 >>> LocationPhysicallyLocatable(o1).getPath() Traceback (most recent call last): ... TypeError: Maximum location depth exceeded, """ \ """probably due to a a location cycle. """ path = [] context = self.context max = 9999 while context is not None: if IRoot.providedBy(context): if path: path.append('') path.reverse() return u'/'.join(path) else: return u'/' path.append(context.__name__) context = context.__parent__ max -= 1 if max < 1: raise TypeError("Maximum location depth exceeded, " "probably due to a a location cycle.") raise TypeError("Not enough context to determine location root") def getParent(self): """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. >>> root = Location() >>> zope.interface.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 """ 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): """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. >>> root = Location() >>> zope.interface.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. >>> zope.interface.noLongerProvides(root, IRoot) >>> LocationPhysicallyLocatable(o2).getParents() Traceback (most recent call last): ... TypeError: Not enough context information to get all parents """ # XXX Merge this implementation with getPath. This was refactored # from zope.traversing. parents = [] w = self.context while 1: w = w.__parent__ 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): """Get a location name See ILocationInfo >>> o1 = Location(); o1.__name__ = u'o1' >>> LocationPhysicallyLocatable(o1).getName() u'o1' """ return self.context.__name__ def getNearestSite(self): """return the nearest site, see ILocationInfo >>> o1 = Location() >>> o1.__name__ = 'o1' >>> LocationPhysicallyLocatable(o1).getNearestSite() Traceback (most recent call last): ... TypeError: Not enough context information to get all parents >>> root = Location() >>> zope.interface.directlyProvides(root, IRoot) >>> o1 = Location() >>> o1.__name__ = 'o1' >>> o1.__parent__ = root >>> LocationPhysicallyLocatable(o1).getNearestSite() is root True >>> zope.interface.directlyProvides( ... o1, zope.component.interfaces.ISite) >>> LocationPhysicallyLocatable(o1).getNearestSite() is o1 True >>> o2 = Location() >>> o2.__parent__ = o1 >>> LocationPhysicallyLocatable(o2).getNearestSite() is o1 True """ if zope.component.interfaces.ISite.providedBy(self.context): return self.context for parent in self.getParents(): if zope.component.interfaces.ISite.providedBy(parent): return parent return self.getRoot() class RootPhysicallyLocatable(object): """Provide location information for the root object >>> from zope.interface.verify import verifyObject >>> info = RootPhysicallyLocatable(None) >>> verifyObject(ILocationInfo, info) True 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. """ zope.component.adapts(IRoot) zope.interface.implements(ILocationInfo) def __init__(self, context): self.context = context def getRoot(self): """See ILocationInfo No need to search for root when our context is already root :) >>> o1 = object() >>> RootPhysicallyLocatable(o1).getRoot() is o1 True """ return self.context def getPath(self): """See ILocationInfo Root object is at the top of the tree, so always return ``/``. >>> o1 = object() >>> RootPhysicallyLocatable(o1).getPath() u'/' """ return u'/' def getName(self): """See ILocationInfo Always return empty unicode string for the root object >>> o1 = object() >>> RootPhysicallyLocatable(o1).getName() u'' """ return u'' def getParent(self): """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. >>> o1 = object() >>> RootPhysicallyLocatable(o1).getParent() """ return None def getParents(self): """See ILocationInfo There's no parents for the root object, return empty list. >>> o1 = object() >>> RootPhysicallyLocatable(o1).getParents() [] """ return [] def getNearestSite(self): """See ILocationInfo 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. >>> o1 = object() >>> RootPhysicallyLocatable(o1).getNearestSite() is o1 True """ return self.context zope.location-3.9.1/src/zope/location/pickling.py0000644000177100020040000000353511624507270023174 0ustar menesismenesis00000000000000############################################################################## # # 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.component import adapts from zope.interface import implements from zope.location.interfaces import ILocation from zope.location.location import inside try: from zope.copy.interfaces import ICopyHook, ResumeCopy except ImportError: raise NotImplementedError("zope.location.pickling is not supported " "because zope.copy is not available") class LocationCopyHook(object): """Copy hook to preserve copying referenced objects that are not located inside object that's being copied. """ adapts(ILocation) implements(ICopyHook) def __init__(self, context): self.context = context def __call__(self, toplevel, register): if not inside(self.context, toplevel): return self.context raise ResumeCopy # BBB 2009-09-02 # The locationCopy was replaced by more generic "clone" function # in the zope.copy package. This reference may be removed someday. from zope.copy import clone as locationCopy # BBB 2009-09-02 # The CopyPersistent was made more generic and moved to the # zope.copy package. This reference may be removed someday. from zope.copy import CopyPersistent zope.location-3.9.1/src/zope/location/configure.zcml0000644000177100020040000000070311624507270023664 0ustar menesismenesis00000000000000 zope.location-3.9.1/src/zope/location/tests.py0000644000177100020040000000201511624507270022526 0ustar menesismenesis00000000000000############################################################################## # # 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 tests """ import doctest import unittest def test_suite(): suite = unittest.TestSuite(( doctest.DocFileSuite('location.txt'), doctest.DocTestSuite('zope.location.traversing'), )) try: import zope.configuration except ImportError: pass else: suite.addTest(doctest.DocFileSuite('configure.txt')) return suite zope.location-3.9.1/src/zope/location/location.py0000644000177100020040000000622411624507270023202 0ustar menesismenesis00000000000000############################################################################## # # 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' import zope.interface import zope.component # XXX import error when doing import zope.location.interfaces :/ from zope.location.interfaces import ILocation from zope.proxy import ProxyBase, non_overridable from zope.proxy.decorator import DecoratorSpecificationDescriptor class Location(object): """Mix-in that implements ILocation. It provides the `__parent__` and `__name__` attributes. """ zope.interface.implements(ILocation) __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 = zope.location.interfaces.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 = l1.__parent__ 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) class LocationProxy(ProxyBase): """Location-object proxy This is a non-picklable proxy that can be put around objects that don't implement `ILocation`. """ zope.component.adapts(zope.interface.Interface) zope.interface.implements(ILocation) __slots__ = '__parent__', '__name__' __safe_for_unpickling__ = True 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 @non_overridable def __reduce__(self, proto=None): raise TypeError("Not picklable") __doc__ = ClassAndInstanceDescr( lambda inst: getProxiedObject(inst).__doc__, lambda cls, __doc__ = __doc__: __doc__, ) __reduce_ex__ = __reduce__ __providedBy__ = DecoratorSpecificationDescriptor() zope.location-3.9.1/src/zope/location/location.txt0000644000177100020040000001031411624507270023364 0ustar menesismenesis00000000000000======== Location ======== Location Base Class ------------------- The `Location` base class is a stupid mix-in that defines `__parent__` and `__name__` attributes. Usage within an Object field: >>> from zope.interface import implements, 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) >>> class A(object): ... implements(IA) ... location = FieldProperty(IA['location']) >>> a = A() >>> a.location = Location() >>> loc = Location(); loc.__name__ = u'foo' >>> a.location = loc >>> loc = Location(); loc.__name__ = None >>> a.location = loc >>> loc = Location(); loc.__name__ = 'foo' >>> a.location = loc Traceback (most recent call last): ... WrongContainedType: ([WrongType('foo', , '__name__')], 'location') The `inside` Function --------------------- The `inside` function tells if l1 is inside l2. L1 is inside l2 if l2 is an ancestor of l1. >>> 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 LocationProxy ------------- The LocationProxy is a non-picklable proxy that can be put around objects that don't implement `ILocation`. >>> 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: >>> p.__doc__ == l.__doc__ True If we get a "located class" somehow, its doc string well be available through proxy as well: >>> class LocalClass(object): ... """This is class that can be located""" >>> p = LocationProxy(LocalClass) >>> p.__doc__ == LocalClass.__doc__ True LocationInterator ----------------- This function allows us to iterate over object and all its parents. >>> from zope.location.location import LocationIterator >>> o1 = Location() >>> o2 = Location() >>> o3 = Location() >>> o3.__parent__ = o2 >>> o2.__parent__ = o1 >>> iter = LocationIterator(o3) >>> iter.next() is o3 True >>> iter.next() is o2 True >>> iter.next() is o1 True >>> iter.next() Traceback (most recent call last): ... StopIteration The `located` function ---------------------- `located` locates an object in another and returns it: >>> 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: >>> 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: >>> 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: >>> 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-3.9.1/src/zope/location/configure.txt0000644000177100020040000000071311624507270023537 0ustar menesismenesis00000000000000Package configuration ===================== The ``zope.location`` package provides a ZCML file that configures some location-related adapters. As we don't have ``zope.copy`` available in our test environment, three adapters get registered: >>> from zope.configuration.xmlconfig import XMLConfig >>> import zope.location >>> XMLConfig('configure.zcml', zope.location)() >>> len(list(zope.component.getGlobalSiteManager().registeredAdapters())) 3 zope.location-3.9.1/src/zope.location.egg-info/0000755000177100020040000000000011624507356022512 5ustar menesismenesis00000000000000zope.location-3.9.1/src/zope.location.egg-info/PKG-INFO0000644000177100020040000002736111624507354023616 0ustar menesismenesis00000000000000Metadata-Version: 1.0 Name: zope.location Version: 3.9.1 Summary: Zope Location Home-page: http://pypi.python.org/pypi/zope.location/ Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Description: Zope Location ============= Overview ======== In Zope3, location are special objects that has a structural location. Detailed Documentation ====================== ======== Location ======== Location Base Class ------------------- The `Location` base class is a stupid mix-in that defines `__parent__` and `__name__` attributes. Usage within an Object field: >>> from zope.interface import implements, 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) >>> class A(object): ... implements(IA) ... location = FieldProperty(IA['location']) >>> a = A() >>> a.location = Location() >>> loc = Location(); loc.__name__ = u'foo' >>> a.location = loc >>> loc = Location(); loc.__name__ = None >>> a.location = loc >>> loc = Location(); loc.__name__ = 'foo' >>> a.location = loc Traceback (most recent call last): ... WrongContainedType: ([WrongType('foo', , '__name__')], 'location') The `inside` Function --------------------- The `inside` function tells if l1 is inside l2. L1 is inside l2 if l2 is an ancestor of l1. >>> 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 LocationProxy ------------- The LocationProxy is a non-picklable proxy that can be put around objects that don't implement `ILocation`. >>> 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: >>> p.__doc__ == l.__doc__ True If we get a "located class" somehow, its doc string well be available through proxy as well: >>> class LocalClass(object): ... """This is class that can be located""" >>> p = LocationProxy(LocalClass) >>> p.__doc__ == LocalClass.__doc__ True LocationInterator ----------------- This function allows us to iterate over object and all its parents. >>> from zope.location.location import LocationIterator >>> o1 = Location() >>> o2 = Location() >>> o3 = Location() >>> o3.__parent__ = o2 >>> o2.__parent__ = o1 >>> iter = LocationIterator(o3) >>> iter.next() is o3 True >>> iter.next() is o2 True >>> iter.next() is o1 True >>> iter.next() Traceback (most recent call last): ... StopIteration The `located` function ---------------------- `located` locates an object in another and returns it: >>> 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: >>> 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: >>> 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: >>> 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 ======= CHANGES ======= 3.9.1 (2011-08-22) ------------------ - Added zcml extra as well as a test for configure.zcml. 3.9.0 (2009-12-29) ------------------ - Moved LocationCopyHook related tests to zope.copy and remove a test dependency on that package. 3.8.2 (2009-12-23) ------------------ - Fixed a typo in the configure.zcml. 3.8.1 (2009-12-23) ------------------ - Removed dependency on zope.copy: the LocationCopyHook adapter is registered only if zope.copy is available. - Use the standard Python doctest module instead of zope.testing.doctest, which has been deprecated. 3.8.0 (2009-12-22) ------------------ - Adjusted to testing output caused by new zope.schema. 3.7.1 (2009-11-18) ------------------ - Moved the IPossibleSite and ISite interfaces to zope.component as they are dealing with zope.component's concept of a site, but not with location. 3.7.0 (2009-09-29) ------------------ - Added getParent() to ILocationInfo and moved the actual implementation here from zope.traversal.api, analogous to getParents(). - Actually removed deprecated PathPersistent class from zope.location.pickling. - Moved ITraverser back to zope.traversing where it belongs conceptually. The interface had been moved to zope.location to invert the package interdependency but is no longer used here. 3.6.0 (2009-08-27) ------------------ - New feature release: deprecated locationCopy, CopyPersistent and PathPersistent from zope.location.pickling. These changes were already part of the 3.5.3 release, which was erroneously numbered as a bugfix relese. - Removed dependency on zope.deferredimport, directly import deprecated modules without using it. 3.5.5 (2009-08-15) ------------------ - Add zope.deferredimport as a dependency as it's used directly by zope.location.pickling. 3.5.4 (2009-05-17) ------------------ - Add ``IContained`` interface to ``zope.location.interfaces`` module. This interface was moved from ``zope.container`` (after ``zope.container`` 3.8.2); consumers of ``IContained`` may now depend on zope.location rather than zope.container to reduce dependency cycles. 3.5.3 (2009-02-09) ------------------ - Use new zope.copy package for implementing location copying. Thus there's changes in the ``zope.locaton.pickling`` module: * The ``locationCopy`` and ``CopyPersistent`` was removed in prefer to their equivalents in zope.copy. Deprecated backward-compatibility imports provided. * The module now provides a ``zope.copy.interfaces.ICopyHook`` adapter for ``ILocation`` objects that replaces the old CopyPersistent functionality of checking for the need to clone objects based on their location. 3.5.2 (2009-02-04) ------------------ - Split RootPhysicallyLocatable adapter back from LocationPhysicallyLocatable, because the IRoot object may not always provide ILocation and the code for the root object is also simplier. It's basically a copy of the RootPhysicallyLocatable adapter from zope.traversing version 3.5.0 and below with ``getParents`` method added (returns an empty list). 3.5.1 (2009-02-02) ------------------ - Improve test coverage. - The new ``getParents`` method was extracted from ``zope.traversing`` and added to ILocationInfo interface in the previous release. Custom ILocationInfo implementations should make sure they have this method as well. That method is already used in ``zope.traversing.api.getParents`` function. - Make ``getName`` of LocationPhysicallyLocatable always return empty string for the IRoot object, like RootPhysicallyLocatable from ``zope.traversing`` did. So, now LocationPhysicallyLocatable is fully compatible with RootPhysicallyLocatable, making the latter one obsolete. - Change package mailing list address to zope-dev at zope.org instead of retired zope3-dev at zope.org. 3.5.0 (2009-01-31) ------------------ - Reverse the dependency between zope.location and zope.traversing. This also causes the dependency to various other packages go away. 3.4.0 (2007-10-02) ------------------ - Initial release independent of the main Zope tree. Keywords: zope location structural Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License Classifier: Programming Language :: Python Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Topic :: Internet :: WWW/HTTP Classifier: Framework :: Zope3 zope.location-3.9.1/src/zope.location.egg-info/top_level.txt0000644000177100020040000000000511624507354025235 0ustar menesismenesis00000000000000zope zope.location-3.9.1/src/zope.location.egg-info/SOURCES.txt0000644000177100020040000000124311624507354024374 0ustar menesismenesis00000000000000CHANGES.txt COPYRIGHT.txt LICENSE.txt README.txt bootstrap.py buildout.cfg setup.py 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.txt src/zope/location/configure.zcml src/zope/location/interfaces.py src/zope/location/location.py src/zope/location/location.txt src/zope/location/pickling.py src/zope/location/tests.py src/zope/location/traversing.pyzope.location-3.9.1/src/zope.location.egg-info/namespace_packages.txt0000644000177100020040000000000511624507354027036 0ustar menesismenesis00000000000000zope zope.location-3.9.1/src/zope.location.egg-info/not-zip-safe0000644000177100020040000000000111624507273024736 0ustar menesismenesis00000000000000 zope.location-3.9.1/src/zope.location.egg-info/dependency_links.txt0000644000177100020040000000000111624507354026556 0ustar menesismenesis00000000000000 zope.location-3.9.1/src/zope.location.egg-info/requires.txt0000644000177100020040000000015011624507354025104 0ustar menesismenesis00000000000000setuptools zope.interface zope.schema>=3.6 zope.component>=3.8 zope.proxy>3.3 [zcml] zope.configurationzope.location-3.9.1/buildout.cfg0000644000177100020040000000060211624507270017746 0ustar menesismenesis00000000000000[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')