zope.minmax-1.1.2/000700 000765 000765 00000000000 11314706202 015160 5ustar00zvezdanzvezdan000000 000000 zope.minmax-1.1.2/bootstrap.py000600 000765 000765 00000003367 11314705405 017566 0ustar00zvezdanzvezdan000000 000000 ############################################################################## # # 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 69908 2006-08-31 21:53:00Z jim $ """ 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.minmax-1.1.2/buildout.cfg000600 000765 000765 00000000250 11314705405 017473 0ustar00zvezdanzvezdan000000 000000 [buildout] develop = . parts = test py [test] recipe = zc.recipe.testrunner eggs = zope.minmax [test] [py] recipe = zc.recipe.egg eggs = zope.minmax interpreter = py zope.minmax-1.1.2/CHANGES.txt000600 000765 000765 00000001060 11314705405 016774 0ustar00zvezdanzvezdan000000 000000 ======= CHANGES ======= 1.1.2 (2009-09-24) ------------------ - Use the standard Python doctest module instead of the deprecated zope.testing.doctest. 1.1.1 (2009-09-09) ------------------ - Fixed homepage link and mailing list address. - Cleaned up. 1.1 (2007-10-02) ---------------- - Refactored package setup. 1.0 (2007-09-28) ---------------- - No further changes since 1.0b2 1.0b2 (2007-07-09) ------------------ - Removed ``_p_independent`` method from ``AbstractValue`` class. 1.0b1 (2007-07-03) ------------------ - Initial release. zope.minmax-1.1.2/PKG-INFO000600 000765 000765 00000017074 11314706202 016270 0ustar00zvezdanzvezdan000000 000000 Metadata-Version: 1.0 Name: zope.minmax Version: 1.1.2 Summary: Homogeneous values favoring maximum or minimum for ZODB conflict resolution Home-page: http://pypi.python.org/pypi/zope.minmax/ Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Description: ================================= Min/Max Value Conflict Resolution ================================= This package provides support for homogeneous values favoring maximum or minimum for ZODB conflict resolution. See ``src/zope/minmax/minmax.txt`` for a detailed description. Detailed Documentation ---------------------- =================================================== Conflict Resolution using Maximum or Minimum Values =================================================== The `zope.minmax.AbstractValue` class provides a super class which can be subclassed to store arbitrary *homogeneous* values in a persistent storage and apply different conflict resolution policies. The subclasses defined here are resolving the conflicts using always either the maximum or the minimum of the conflicting values. Maximum ------- The `zope.minmax.Maximum` class always resolves conflicts favoring the maximum value. Let's instantiate one object and verify that it satisfies the interface. >>> import zope.minmax >>> import zope.interface.verify >>> max_favored = zope.minmax.Maximum() >>> zope.interface.verify.verifyObject( ... zope.minmax.interfaces.IAbstractValue, max_favored) True We can confirm that the initial value is zero. >>> bool(max_favored) False >>> print max_favored.value None Now, we can store a new value in the object. >>> max_favored.value = 11 >>> print max_favored.value 11 >>> bool(max_favored) True Or we can use the methods. >>> max_favored.__setstate__(4532) >>> max_favored.__getstate__() 4532 >>> print max_favored.value 4532 >>> bool(max_favored) True Do notice that using a direct assignment to the value attribute is a more natural use. Minimum ------- The `zope.minmax.Minimum` class always resolves conflicts favoring the minimum value. Again, we instantiate an object and verify that it satisfies the interface. >>> min_favored = zope.minmax.Minimum() >>> zope.interface.verify.verifyObject( ... zope.minmax.interfaces.IAbstractValue, min_favored) True We need a confirmation that the initial value is zero. >>> bool(min_favored) False >>> print min_favored.value None Let's populate this one too. >>> min_favored.value = 22 >>> print min_favored.value 22 >>> bool(min_favored) True Or we can use the methods, again. >>> min_favored.__setstate__(8796) >>> min_favored.__getstate__() 8796 >>> print min_favored.value 8796 >>> bool(min_favored) True Please, notice, again, that using a direct assignment to the value attribute is a more natural use. Conflict Resolution ------------------- Now, we need to exercise the conflict resolution interface. First for the `zope.minmax.Maximum`: Let's try differing values larger than the old value. >>> max_favored._p_resolveConflict(max_favored.value, 4536, 4535) 4536 >>> max_favored._p_resolveConflict(max_favored.value, 4573, 4574) 4574 What happens when all the values are equal, including the old. >>> max_favored._p_resolveConflict(max_favored.value, 4532, 4532) 4532 Notice that when the old value is larger than both the committed and new, it is still disregarded. >>> max_favored._p_resolveConflict(max_favored.value, 4531, 4530) 4531 Now, the `zope.minmax.Minimum`: Let's try differing values smaller than the old value. >>> min_favored._p_resolveConflict(min_favored.value, 8792, 8791) 8791 >>> min_favored._p_resolveConflict(min_favored.value, 8785, 8786) 8785 What happens when all the values are equal, including the old. >>> min_favored._p_resolveConflict(min_favored.value, 8796, 8796) 8796 Notice that when the old value is smaller than both the committed and new, it is still disregarded. >>> min_favored._p_resolveConflict(min_favored.value, 8798, 8799) 8798 How about an example that is not numerical? >>> max_word = zope.minmax.Maximum('joy') >>> print max_word.value joy >>> bool(max_word) True >>> max_word._p_resolveConflict(max_word.value, 'happiness', 'exuberance') 'happiness' >>> max_word._p_resolveConflict(max_word.value, 'exuberance', 'happiness') 'happiness' >>> min_word = zope.minmax.Minimum(max_word.value) >>> print min_word.value joy >>> bool(min_word) True >>> min_word._p_resolveConflict(min_word.value, 'happiness', 'exuberance') 'exuberance' >>> min_word._p_resolveConflict(min_word.value, 'exuberance', 'happiness') 'exuberance' As indicated, we don't need to have numbers, just *homegeneous* items. The homogeneous values are not really inherently required. However, it makes no sense to apply min() or max() on, say, one number and one string. Simply, the ordering relations do not work at all on heterogeneous values. ======= CHANGES ======= 1.1.2 (2009-09-24) ------------------ - Use the standard Python doctest module instead of the deprecated zope.testing.doctest. 1.1.1 (2009-09-09) ------------------ - Fixed homepage link and mailing list address. - Cleaned up. 1.1 (2007-10-02) ---------------- - Refactored package setup. 1.0 (2007-09-28) ---------------- - No further changes since 1.0b2 1.0b2 (2007-07-09) ------------------ - Removed ``_p_independent`` method from ``AbstractValue`` class. 1.0b1 (2007-07-03) ------------------ - Initial release. Keywords: zope3 zope zodb minimum maximum conflict resolution Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Framework :: Zope3 Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Internet :: WWW/HTTP Classifier: Topic :: Software Development :: Libraries :: Python Modules zope.minmax-1.1.2/README.txt000600 000765 000765 00000000426 11314705405 016666 0ustar00zvezdanzvezdan000000 000000 ================================= Min/Max Value Conflict Resolution ================================= This package provides support for homogeneous values favoring maximum or minimum for ZODB conflict resolution. See ``src/zope/minmax/minmax.txt`` for a detailed description. zope.minmax-1.1.2/setup.cfg000600 000765 000765 00000000073 11314706202 017003 0ustar00zvezdanzvezdan000000 000000 [egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 zope.minmax-1.1.2/setup.py000600 000765 000765 00000005220 11314705544 016703 0ustar00zvezdanzvezdan000000 000000 ############################################################################## # # Copyright (c) 2007 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.minmax 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.minmax', version='1.1.2', author='Zope Corporation and Contributors', author_email='zope-dev@zope.org', description=( "Homogeneous values favoring maximum or minimum for ZODB " "conflict resolution" ), long_description=( read('README.txt') + '\n\n' + 'Detailed Documentation\n' + '----------------------' + '\n\n' + read('src', 'zope', 'minmax', 'minmax.txt') + '\n\n' + read('CHANGES.txt') ), license='ZPL 2.1', keywords=('zope3 zope zodb minimum maximum conflict resolution'), classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment', 'Framework :: Zope3', 'Intended Audience :: Developers', 'License :: OSI Approved :: Zope Public License', 'Natural Language :: English', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Software Development :: Libraries :: Python Modules', ], url='http://pypi.python.org/pypi/zope.minmax/', packages=find_packages('src'), package_dir={'': 'src'}, namespace_packages=['zope',], extras_require=dict( test=[], # removed zope.testing; leaving for backward compatibility ), install_requires=[ 'setuptools', 'ZODB3', 'zope.interface', ], include_package_data=True, zip_safe=False, ) zope.minmax-1.1.2/src/000700 000765 000765 00000000000 11314706202 015747 5ustar00zvezdanzvezdan000000 000000 zope.minmax-1.1.2/src/zope/000700 000765 000765 00000000000 11314706202 016724 5ustar00zvezdanzvezdan000000 000000 zope.minmax-1.1.2/src/zope.minmax.egg-info/000700 000765 000765 00000000000 11314706202 021706 5ustar00zvezdanzvezdan000000 000000 zope.minmax-1.1.2/src/zope.minmax.egg-info/dependency_links.txt000600 000765 000765 00000000001 11314706202 025756 0ustar00zvezdanzvezdan000000 000000 zope.minmax-1.1.2/src/zope.minmax.egg-info/namespace_packages.txt000600 000765 000765 00000000005 11314706202 026236 0ustar00zvezdanzvezdan000000 000000 zope zope.minmax-1.1.2/src/zope.minmax.egg-info/not-zip-safe000600 000765 000765 00000000001 11314705425 024144 0ustar00zvezdanzvezdan000000 000000 zope.minmax-1.1.2/src/zope.minmax.egg-info/PKG-INFO000600 000765 000765 00000017074 11314706202 023016 0ustar00zvezdanzvezdan000000 000000 Metadata-Version: 1.0 Name: zope.minmax Version: 1.1.2 Summary: Homogeneous values favoring maximum or minimum for ZODB conflict resolution Home-page: http://pypi.python.org/pypi/zope.minmax/ Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Description: ================================= Min/Max Value Conflict Resolution ================================= This package provides support for homogeneous values favoring maximum or minimum for ZODB conflict resolution. See ``src/zope/minmax/minmax.txt`` for a detailed description. Detailed Documentation ---------------------- =================================================== Conflict Resolution using Maximum or Minimum Values =================================================== The `zope.minmax.AbstractValue` class provides a super class which can be subclassed to store arbitrary *homogeneous* values in a persistent storage and apply different conflict resolution policies. The subclasses defined here are resolving the conflicts using always either the maximum or the minimum of the conflicting values. Maximum ------- The `zope.minmax.Maximum` class always resolves conflicts favoring the maximum value. Let's instantiate one object and verify that it satisfies the interface. >>> import zope.minmax >>> import zope.interface.verify >>> max_favored = zope.minmax.Maximum() >>> zope.interface.verify.verifyObject( ... zope.minmax.interfaces.IAbstractValue, max_favored) True We can confirm that the initial value is zero. >>> bool(max_favored) False >>> print max_favored.value None Now, we can store a new value in the object. >>> max_favored.value = 11 >>> print max_favored.value 11 >>> bool(max_favored) True Or we can use the methods. >>> max_favored.__setstate__(4532) >>> max_favored.__getstate__() 4532 >>> print max_favored.value 4532 >>> bool(max_favored) True Do notice that using a direct assignment to the value attribute is a more natural use. Minimum ------- The `zope.minmax.Minimum` class always resolves conflicts favoring the minimum value. Again, we instantiate an object and verify that it satisfies the interface. >>> min_favored = zope.minmax.Minimum() >>> zope.interface.verify.verifyObject( ... zope.minmax.interfaces.IAbstractValue, min_favored) True We need a confirmation that the initial value is zero. >>> bool(min_favored) False >>> print min_favored.value None Let's populate this one too. >>> min_favored.value = 22 >>> print min_favored.value 22 >>> bool(min_favored) True Or we can use the methods, again. >>> min_favored.__setstate__(8796) >>> min_favored.__getstate__() 8796 >>> print min_favored.value 8796 >>> bool(min_favored) True Please, notice, again, that using a direct assignment to the value attribute is a more natural use. Conflict Resolution ------------------- Now, we need to exercise the conflict resolution interface. First for the `zope.minmax.Maximum`: Let's try differing values larger than the old value. >>> max_favored._p_resolveConflict(max_favored.value, 4536, 4535) 4536 >>> max_favored._p_resolveConflict(max_favored.value, 4573, 4574) 4574 What happens when all the values are equal, including the old. >>> max_favored._p_resolveConflict(max_favored.value, 4532, 4532) 4532 Notice that when the old value is larger than both the committed and new, it is still disregarded. >>> max_favored._p_resolveConflict(max_favored.value, 4531, 4530) 4531 Now, the `zope.minmax.Minimum`: Let's try differing values smaller than the old value. >>> min_favored._p_resolveConflict(min_favored.value, 8792, 8791) 8791 >>> min_favored._p_resolveConflict(min_favored.value, 8785, 8786) 8785 What happens when all the values are equal, including the old. >>> min_favored._p_resolveConflict(min_favored.value, 8796, 8796) 8796 Notice that when the old value is smaller than both the committed and new, it is still disregarded. >>> min_favored._p_resolveConflict(min_favored.value, 8798, 8799) 8798 How about an example that is not numerical? >>> max_word = zope.minmax.Maximum('joy') >>> print max_word.value joy >>> bool(max_word) True >>> max_word._p_resolveConflict(max_word.value, 'happiness', 'exuberance') 'happiness' >>> max_word._p_resolveConflict(max_word.value, 'exuberance', 'happiness') 'happiness' >>> min_word = zope.minmax.Minimum(max_word.value) >>> print min_word.value joy >>> bool(min_word) True >>> min_word._p_resolveConflict(min_word.value, 'happiness', 'exuberance') 'exuberance' >>> min_word._p_resolveConflict(min_word.value, 'exuberance', 'happiness') 'exuberance' As indicated, we don't need to have numbers, just *homegeneous* items. The homogeneous values are not really inherently required. However, it makes no sense to apply min() or max() on, say, one number and one string. Simply, the ordering relations do not work at all on heterogeneous values. ======= CHANGES ======= 1.1.2 (2009-09-24) ------------------ - Use the standard Python doctest module instead of the deprecated zope.testing.doctest. 1.1.1 (2009-09-09) ------------------ - Fixed homepage link and mailing list address. - Cleaned up. 1.1 (2007-10-02) ---------------- - Refactored package setup. 1.0 (2007-09-28) ---------------- - No further changes since 1.0b2 1.0b2 (2007-07-09) ------------------ - Removed ``_p_independent`` method from ``AbstractValue`` class. 1.0b1 (2007-07-03) ------------------ - Initial release. Keywords: zope3 zope zodb minimum maximum conflict resolution Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Framework :: Zope3 Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Internet :: WWW/HTTP Classifier: Topic :: Software Development :: Libraries :: Python Modules zope.minmax-1.1.2/src/zope.minmax.egg-info/requires.txt000600 000765 000765 00000000050 11314706202 024303 0ustar00zvezdanzvezdan000000 000000 setuptools ZODB3 zope.interface [test] zope.minmax-1.1.2/src/zope.minmax.egg-info/SOURCES.txt000600 000765 000765 00000000757 11314706202 023605 0ustar00zvezdanzvezdan000000 000000 CHANGES.txt README.txt bootstrap.py buildout.cfg setup.py src/zope/__init__.py src/zope.minmax.egg-info/PKG-INFO src/zope.minmax.egg-info/SOURCES.txt src/zope.minmax.egg-info/dependency_links.txt src/zope.minmax.egg-info/namespace_packages.txt src/zope.minmax.egg-info/not-zip-safe src/zope.minmax.egg-info/requires.txt src/zope.minmax.egg-info/top_level.txt src/zope/minmax/__init__.py src/zope/minmax/_minmax.py src/zope/minmax/interfaces.py src/zope/minmax/minmax.txt src/zope/minmax/tests.pyzope.minmax-1.1.2/src/zope.minmax.egg-info/top_level.txt000600 000765 000765 00000000005 11314706202 024435 0ustar00zvezdanzvezdan000000 000000 zope zope.minmax-1.1.2/src/zope/__init__.py000600 000765 000765 00000000070 11314705405 021040 0ustar00zvezdanzvezdan000000 000000 __import__('pkg_resources').declare_namespace(__name__) zope.minmax-1.1.2/src/zope/minmax/000700 000765 000765 00000000000 11314706202 020215 5ustar00zvezdanzvezdan000000 000000 zope.minmax-1.1.2/src/zope/minmax/__init__.py000600 000765 000765 00000000061 11314705405 022331 0ustar00zvezdanzvezdan000000 000000 from zope.minmax._minmax import Maximum, Minimum zope.minmax-1.1.2/src/zope/minmax/_minmax.py000600 000765 000765 00000001602 11314705405 022224 0ustar00zvezdanzvezdan000000 000000 import persistent import zope.interface from zope.minmax import interfaces class AbstractValue(persistent.Persistent): zope.interface.implements(interfaces.IAbstractValue) def __init__(self, value=None): self.value = value def __getstate__(self): return self.value def __setstate__(self, value): self.value = value def __nonzero__(self): return bool(self.value) def _p_resolveConflict(self, old, commited, new): raise NotImplementedError() class Maximum(AbstractValue): def _p_resolveConflict(self, old, commited, new): # including old does not seem logical but it's open to discussion return max(commited, new) class Minimum(AbstractValue): def _p_resolveConflict(self, old, commited, new): # including old does not seem logical but it's open to discussion return min(commited, new) zope.minmax-1.1.2/src/zope/minmax/interfaces.py000600 000765 000765 00000000561 11314705405 022722 0ustar00zvezdanzvezdan000000 000000 import persistent.interfaces import zope.interface class IAbstractValue(persistent.interfaces.IPersistent): """A persistent value with the conflict resolution. The values are expected to be homogeneous. """ value = zope.interface.Attribute('The initial value') def __nonzero__(): """Return Boolean cast of the value as True or False.""" zope.minmax-1.1.2/src/zope/minmax/minmax.txt000600 000765 000765 00000010726 11314705405 022263 0ustar00zvezdanzvezdan000000 000000 =================================================== Conflict Resolution using Maximum or Minimum Values =================================================== The `zope.minmax.AbstractValue` class provides a super class which can be subclassed to store arbitrary *homogeneous* values in a persistent storage and apply different conflict resolution policies. The subclasses defined here are resolving the conflicts using always either the maximum or the minimum of the conflicting values. Maximum ------- The `zope.minmax.Maximum` class always resolves conflicts favoring the maximum value. Let's instantiate one object and verify that it satisfies the interface. >>> import zope.minmax >>> import zope.interface.verify >>> max_favored = zope.minmax.Maximum() >>> zope.interface.verify.verifyObject( ... zope.minmax.interfaces.IAbstractValue, max_favored) True We can confirm that the initial value is zero. >>> bool(max_favored) False >>> print max_favored.value None Now, we can store a new value in the object. >>> max_favored.value = 11 >>> print max_favored.value 11 >>> bool(max_favored) True Or we can use the methods. >>> max_favored.__setstate__(4532) >>> max_favored.__getstate__() 4532 >>> print max_favored.value 4532 >>> bool(max_favored) True Do notice that using a direct assignment to the value attribute is a more natural use. Minimum ------- The `zope.minmax.Minimum` class always resolves conflicts favoring the minimum value. Again, we instantiate an object and verify that it satisfies the interface. >>> min_favored = zope.minmax.Minimum() >>> zope.interface.verify.verifyObject( ... zope.minmax.interfaces.IAbstractValue, min_favored) True We need a confirmation that the initial value is zero. >>> bool(min_favored) False >>> print min_favored.value None Let's populate this one too. >>> min_favored.value = 22 >>> print min_favored.value 22 >>> bool(min_favored) True Or we can use the methods, again. >>> min_favored.__setstate__(8796) >>> min_favored.__getstate__() 8796 >>> print min_favored.value 8796 >>> bool(min_favored) True Please, notice, again, that using a direct assignment to the value attribute is a more natural use. Conflict Resolution ------------------- Now, we need to exercise the conflict resolution interface. First for the `zope.minmax.Maximum`: Let's try differing values larger than the old value. >>> max_favored._p_resolveConflict(max_favored.value, 4536, 4535) 4536 >>> max_favored._p_resolveConflict(max_favored.value, 4573, 4574) 4574 What happens when all the values are equal, including the old. >>> max_favored._p_resolveConflict(max_favored.value, 4532, 4532) 4532 Notice that when the old value is larger than both the committed and new, it is still disregarded. >>> max_favored._p_resolveConflict(max_favored.value, 4531, 4530) 4531 Now, the `zope.minmax.Minimum`: Let's try differing values smaller than the old value. >>> min_favored._p_resolveConflict(min_favored.value, 8792, 8791) 8791 >>> min_favored._p_resolveConflict(min_favored.value, 8785, 8786) 8785 What happens when all the values are equal, including the old. >>> min_favored._p_resolveConflict(min_favored.value, 8796, 8796) 8796 Notice that when the old value is smaller than both the committed and new, it is still disregarded. >>> min_favored._p_resolveConflict(min_favored.value, 8798, 8799) 8798 How about an example that is not numerical? >>> max_word = zope.minmax.Maximum('joy') >>> print max_word.value joy >>> bool(max_word) True >>> max_word._p_resolveConflict(max_word.value, 'happiness', 'exuberance') 'happiness' >>> max_word._p_resolveConflict(max_word.value, 'exuberance', 'happiness') 'happiness' >>> min_word = zope.minmax.Minimum(max_word.value) >>> print min_word.value joy >>> bool(min_word) True >>> min_word._p_resolveConflict(min_word.value, 'happiness', 'exuberance') 'exuberance' >>> min_word._p_resolveConflict(min_word.value, 'exuberance', 'happiness') 'exuberance' As indicated, we don't need to have numbers, just *homegeneous* items. The homogeneous values are not really inherently required. However, it makes no sense to apply min() or max() on, say, one number and one string. Simply, the ordering relations do not work at all on heterogeneous values. zope.minmax-1.1.2/src/zope/minmax/tests.py000600 000765 000765 00000000321 11314705405 021733 0ustar00zvezdanzvezdan000000 000000 import doctest import unittest def test_suite(): return unittest.TestSuite(( doctest.DocFileSuite('minmax.txt'), )) if __name__ == '__main__': unittest.main(defaultTest='test_suite')