zope.app.dependable-3.5.1/bootstrap.py0000644000000000000000000000337010601422174017663 0ustar rootroot00000000000000############################################################################## # # Copyright (c) 2006 Zope Corporation 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. $Id: bootstrap.py 73539 2007-03-25 08:27:56Z dobe $ """ import os, shutil, sys, tempfile, urllib2 tmpeggs = tempfile.mkdtemp() ez = {} exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py' ).read() in ez ez['use_setuptools'](to_dir=tmpeggs, download_delay=0) import pkg_resources cmd = 'from setuptools.command.easy_install import main; main()' if sys.platform == 'win32': cmd = '"%s"' % cmd # work around spawn lamosity on windows ws = pkg_resources.working_set assert os.spawnle( os.P_WAIT, sys.executable, sys.executable, '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout', dict(os.environ, PYTHONPATH= ws.find(pkg_resources.Requirement.parse('setuptools')).location ), ) == 0 ws.add_entry(tmpeggs) ws.require('zc.buildout') import zc.buildout.buildout zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap']) shutil.rmtree(tmpeggs) zope.app.dependable-3.5.1/buildout.cfg0000644000000000000000000000015410707520564017612 0ustar rootroot00000000000000[buildout] develop = . parts = test [test] recipe = zc.recipe.testrunner eggs = zope.app.dependable [test] zope.app.dependable-3.5.1/CHANGES.txt0000644000000000000000000000055411311772656017122 0ustar rootroot00000000000000======= CHANGES ======= 3.5.1 (2009-12-15) ------------------ - Added missing zcml namespace to the configure file. 3.5.0 (2009-12-15) ------------------ - Moved CheckDependency event handler and its tests into this package from its former place in zope.container. 3.4.0 (2007-10-23) ------------------ - Initial release independent of the main Zope tree. zope.app.dependable-3.5.1/PKG-INFO0000644000000000000000000000241711311772716016403 0ustar rootroot00000000000000Metadata-Version: 1.0 Name: zope.app.dependable Version: 3.5.1 Summary: Simple Dependency API Home-page: http://pypi.python.org/pypi/zope.app.dependable Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Description: A simple object-dependency framework for Zope. ======= CHANGES ======= 3.5.1 (2009-12-15) ------------------ - Added missing zcml namespace to the configure file. 3.5.0 (2009-12-15) ------------------ - Moved CheckDependency event handler and its tests into this package from its former place in zope.container. 3.4.0 (2007-10-23) ------------------ - Initial release independent of the main Zope tree. Keywords: zope3 dependency 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.app.dependable-3.5.1/README.txt0000644000000000000000000000005710707520564017002 0ustar rootroot00000000000000A simple object-dependency framework for Zope. zope.app.dependable-3.5.1/setup.cfg0000644000000000000000000000007311311772716017123 0ustar rootroot00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 zope.app.dependable-3.5.1/setup.py0000644000000000000000000000517511311772704017021 0ustar rootroot00000000000000############################################################################## # # Copyright (c) 2006 Zope Corporation 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.app.dependable package $Id: setup.py 106589 2009-12-15 21:46:59Z hannosch $ """ import os from setuptools import setup, find_packages def read(*rnames): return open(os.path.join(os.path.dirname(__file__), *rnames)).read() setup(name='zope.app.dependable', version = '3.5.1', author='Zope Corporation and Contributors', author_email='zope-dev@zope.org', description='Simple Dependency API', long_description=( read('README.txt') + '\n\n' + read('CHANGES.txt') ), keywords = "zope3 dependency", 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.app.dependable', license='ZPL 2.1', packages=find_packages('src'), package_dir = {'': 'src'}, namespace_packages=['zope', 'zope.app'], extras_require=dict(test=['zope.app.testing']), install_requires=['setuptools', 'zope.annotation', 'zope.exceptions', 'zope.i18nmessageid', 'zope.interface', 'zope.lifecycleevent', 'zope.location', 'zope.traversing', ], include_package_data = True, zip_safe = False, ) zope.app.dependable-3.5.1/src/zope/__init__.py0000644000000000000000000000031110601422174021141 0ustar rootroot00000000000000# this is a namespace package try: import pkg_resources pkg_resources.declare_namespace(__name__) except ImportError: import pkgutil __path__ = pkgutil.extend_path(__path__, __name__) zope.app.dependable-3.5.1/src/zope/app/__init__.py0000644000000000000000000000031110601422174021721 0ustar rootroot00000000000000# this is a namespace package try: import pkg_resources pkg_resources.declare_namespace(__name__) except ImportError: import pkgutil __path__ = pkgutil.extend_path(__path__, __name__) zope.app.dependable-3.5.1/src/zope/app/dependable/__init__.py0000644000000000000000000000663310424004032024011 0ustar rootroot00000000000000############################################################################## # # Copyright (c) 2002 Zope Corporation 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. # ############################################################################## """Dependable Framework. $Id: __init__.py 67630 2006-04-27 00:54:03Z jim $ """ __docformat__ = 'restructuredtext' from zope.interface import implements from zope.traversing.api import getParent, canonicalPath, getPath from zope.annotation.interfaces import IAnnotations from zope.app.dependable.interfaces import IDependable class PathSetAnnotation(object): """Abstract base class for annotations that are sets of paths. To make this into a concrete class, a subclass must set the class attribute `key` to a unique annotation key. A subclass may also choose to rename the methods. """ def __init__(self, context): self.context = context try: parent = getParent(self.context) except TypeError: parent = None if parent is not None: try: pp = getPath(parent) except TypeError: pp = "" if not pp.endswith("/"): pp += "/" self.pp = pp # parentpath else: self.pp = "" self.pplen = len(self.pp) def addPath(self, path): path = self._make_relative(path) annotations = IAnnotations(self.context) old = annotations.get(self.key, ()) fixed = map(self._make_relative, old) if path not in fixed: fixed.append(path) new = tuple(fixed) if new != old: annotations[self.key] = new def removePath(self, path): path = self._make_relative(path) annotations = IAnnotations(self.context) old = annotations.get(self.key, ()) if old: fixed = map(self._make_relative, old) fixed = [loc for loc in fixed if loc != path] new = tuple(fixed) if new != old: if new: annotations[self.key] = new else: del annotations[self.key] def getPaths(self): annotations = IAnnotations(self.context) locs = annotations.get(self.key, ()) return tuple(map(self._make_absolute, locs)) def _make_relative(self, path): if path.startswith("/") and self.pp: path = canonicalPath(path) if path.startswith(self.pp): path = path[self.pplen:] while path.startswith("/"): path = path[1:] return path def _make_absolute(self, path): if not path.startswith("/") and self.pp: path = self.pp + path return path class Dependable(PathSetAnnotation): """See `IDependable`.""" implements(IDependable) key = "zope.app.dependable.Dependents" addDependent = PathSetAnnotation.addPath removeDependent = PathSetAnnotation.removePath dependents = PathSetAnnotation.getPaths zope.app.dependable-3.5.1/src/zope/app/dependable/configure.zcml0000644000000000000000000000075711311772552024570 0ustar rootroot00000000000000 zope.app.dependable-3.5.1/src/zope/app/dependable/dependency.py0000644000000000000000000000317511311766344024407 0ustar rootroot00000000000000############################################################################## # # Copyright (c) 2002 Zope Corporation 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. # ############################################################################## """Subscriber function checking dependencies if a removal is performed on an object having dependencies. It raises an exception if it's the case. """ __docformat__ = 'restructuredtext' from zope.i18nmessageid import Message from zope.i18nmessageid import MessageFactory from zope.location.interfaces import ILocationInfo from zope.app.dependable.interfaces import IDependable, DependencyError _ = MessageFactory('zope') exception_msg = _(""" Removal of object (${object}) which has dependents (${dependents}) is not possible ! You must deactivate this object before trying to remove it. """) def CheckDependency(event): object = event.object dependency = IDependable(object, None) if dependency is not None: dependents = dependency.dependents() if dependents: mapping = { "object": ILocationInfo(object).getPath(), "dependents": ", ".join(dependents) } raise DependencyError(Message(exception_msg, mapping=mapping)) zope.app.dependable-3.5.1/src/zope/app/dependable/interfaces.py0000644000000000000000000000277410424004032024377 0ustar rootroot00000000000000############################################################################## # # Copyright (c) 2002 Zope Corporation 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. # ############################################################################## """Dependable framework interfaces $Id: interfaces.py 67630 2006-04-27 00:54:03Z jim $ """ __docformat__ = 'restructuredtext' from zope.interface import Interface from zope.exceptions.interfaces import UserError class IDependable(Interface): """Objects that other objects depend on. Note that `IDependable` will normally be implemented by an adapter. """ def addDependent(location): """Add a dependency to a dependent object by location The location is the physical path to the dependent object. """ def removeDependent(location): """Remove a dependency with a dependent object by location. The location is the physical path to the dependent object. """ def dependents(): """Return a sequence of dependent object locations. """ class DependencyError(UserError): """ This object is dependable""" zope.app.dependable-3.5.1/src/zope/app/dependable/tests.py0000644000000000000000000000657711311767530023442 0ustar rootroot00000000000000############################################################################## # # Copyright (c) 2001, 2002 Zope Corporation 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. # ############################################################################## """Unit tests for Dependable class. $Id: tests.py 106578 2009-12-15 21:19:35Z hannosch $ """ from unittest import TestCase, TestSuite, main, makeSuite from zope.annotation.attribute import AttributeAnnotations from zope.app.testing.placelesssetup import PlacelessSetup from zope.interface import implements from zope.lifecycleevent import ObjectRemovedEvent from zope.traversing.interfaces import IPhysicallyLocatable from zope.app.dependable.dependency import CheckDependency from zope.app.dependable.interfaces import IDependable, DependencyError class C(object): pass class DummyObject(object): implements(IDependable, IPhysicallyLocatable) def dependents(self): return ['dependency1', 'dependency2'] def getPath(self): return '/dummy-object' class Test(PlacelessSetup, TestCase): def factory(self): from zope.app.dependable import Dependable return Dependable(AttributeAnnotations(C())) def testVerifyInterface(self): from zope.interface.verify import verifyObject from zope.app.dependable.interfaces import IDependable object = self.factory() verifyObject(IDependable, object) def testBasic(self): dependable = self.factory() self.failIf(dependable.dependents()) dependable.addDependent('/a/b') dependable.addDependent('/c/d') dependable.addDependent('/c/e') dependable.addDependent('/c/d') dependents = list(dependable.dependents()) dependents.sort() self.assertEqual(dependents, ['/a/b', '/c/d', '/c/e']) dependable.removeDependent('/c/d') dependents = list(dependable.dependents()) dependents.sort() self.assertEqual(dependents, ['/a/b', '/c/e']) dependable.removeDependent('/c/d') dependents = list(dependable.dependents()) dependents.sort() self.assertEqual(dependents, ['/a/b', '/c/e']) def testRelativeAbsolute(self): obj = self.factory() # Hack the object to have a parent path obj.pp = "/a/" obj.pplen = len(obj.pp) obj.addDependent("foo") self.assertEqual(obj.dependents(), ("/a/foo",)) obj.removeDependent("/a/foo") self.assertEqual(obj.dependents(), ()) obj.addDependent("/a/bar") self.assertEqual(obj.dependents(), ("/a/bar",)) obj.removeDependent("bar") self.assertEqual(obj.dependents(), ()) def testCheckDependency(self): obj = DummyObject() parent = object() event = ObjectRemovedEvent(obj, parent, 'oldName') self.assertRaises(DependencyError, CheckDependency, event) def test_suite(): return TestSuite(( makeSuite(Test), )) if __name__=='__main__': main(defaultTest='test_suite') zope.app.dependable-3.5.1/src/zope.app.dependable.egg-info/dependency_links.txt0000644000000000000000000000000111311772716027447 0ustar rootroot00000000000000 zope.app.dependable-3.5.1/src/zope.app.dependable.egg-info/namespace_packages.txt0000644000000000000000000000001611311772716027731 0ustar rootroot00000000000000zope zope.app zope.app.dependable-3.5.1/src/zope.app.dependable.egg-info/not-zip-safe0000644000000000000000000000000111311767250025624 0ustar rootroot00000000000000 zope.app.dependable-3.5.1/src/zope.app.dependable.egg-info/PKG-INFO0000644000000000000000000000241711311772716024502 0ustar rootroot00000000000000Metadata-Version: 1.0 Name: zope.app.dependable Version: 3.5.1 Summary: Simple Dependency API Home-page: http://pypi.python.org/pypi/zope.app.dependable Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Description: A simple object-dependency framework for Zope. ======= CHANGES ======= 3.5.1 (2009-12-15) ------------------ - Added missing zcml namespace to the configure file. 3.5.0 (2009-12-15) ------------------ - Moved CheckDependency event handler and its tests into this package from its former place in zope.container. 3.4.0 (2007-10-23) ------------------ - Initial release independent of the main Zope tree. Keywords: zope3 dependency 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.app.dependable-3.5.1/src/zope.app.dependable.egg-info/requires.txt0000644000000000000000000000022711311772716026002 0ustar rootroot00000000000000setuptools zope.annotation zope.exceptions zope.i18nmessageid zope.interface zope.lifecycleevent zope.location zope.traversing [test] zope.app.testingzope.app.dependable-3.5.1/src/zope.app.dependable.egg-info/SOURCES.txt0000644000000000000000000000115711311772716025271 0ustar rootroot00000000000000CHANGES.txt README.txt bootstrap.py buildout.cfg setup.py src/zope/__init__.py src/zope.app.dependable.egg-info/PKG-INFO src/zope.app.dependable.egg-info/SOURCES.txt src/zope.app.dependable.egg-info/dependency_links.txt src/zope.app.dependable.egg-info/namespace_packages.txt src/zope.app.dependable.egg-info/not-zip-safe src/zope.app.dependable.egg-info/requires.txt src/zope.app.dependable.egg-info/top_level.txt src/zope/app/__init__.py src/zope/app/dependable/__init__.py src/zope/app/dependable/configure.zcml src/zope/app/dependable/dependency.py src/zope/app/dependable/interfaces.py src/zope/app/dependable/tests.pyzope.app.dependable-3.5.1/src/zope.app.dependable.egg-info/top_level.txt0000644000000000000000000000000511311772716026126 0ustar rootroot00000000000000zope