Commit 4e778be2 authored by Bernd Dorn's avatar Bernd Dorn

new bootstrap, store length in btree containers, version bump to 3.5

parent dcc461b9
zope.app.apidoc Package Changelog
=================================
Changes for zope.app.container
==============================
Version 3.5.0a1
===============
- updated bootstrap to current version
- Store length of BTreeContainer in its own Length object for faster
__len__ implementation of huge containers.
......@@ -24,12 +24,15 @@ 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)
try:
import pkg_resources
except ImportError:
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
import pkg_resources
cmd = 'from setuptools.command.easy_install import main; main()'
if sys.platform == 'win32':
......@@ -50,3 +53,4 @@ ws.require('zc.buildout')
import zc.buildout.buildout
zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
shutil.rmtree(tmpeggs)
......@@ -21,7 +21,7 @@ import os
from setuptools import setup, find_packages, Extension
setup(name='zope.app.container',
version = '3.4.0b1',
version = '3.5.0a1',
url='http://svn.zope.org/zope.app.container',
license='ZPL 2.1',
description='Zope container',
......
......@@ -24,7 +24,10 @@ __docformat__ = 'restructuredtext'
from persistent import Persistent
from BTrees.OOBTree import OOBTree
from BTrees.Length import Length
from zope.app.container.sample import SampleContainer
from zope.cachedescriptors.property import Lazy
class BTreeContainer(SampleContainer, Persistent):
......@@ -36,6 +39,10 @@ class BTreeContainer(SampleContainer, Persistent):
# operations on the BTree itself. It would probably be clearer to
# just delegate those methods directly to the btree.
def __init__(self):
super(BTreeContainer, self).__init__()
self.__len = Length()
def _newContainerData(self):
"""Construct an item-data container
......@@ -63,5 +70,32 @@ class BTreeContainer(SampleContainer, Persistent):
'''
return key in self._SampleContainer__data
@Lazy
def _BTreeContainer__len(self):
import logging
log = logging.getLogger('zope.app.container.btree')
l=Length()
ol = super(BTreeContainer, self).__len__()
if ol>0:
l.change(ol)
self._p_changed=True
log.info("Storing length of %r" % self)
return l
def __len__(self):
#import pdb;pdb.set_trace()
return self.__len()
def __setitem__(self, key, value):
# make sure our lazy property gets set
l = self.__len
super(BTreeContainer, self).__setitem__(key, value)
l.change(1)
def __delitem__(self, key):
# make sure our lazy property gets set
l = self.__len
super(BTreeContainer, self).__delitem__(key)
l.change(-1)
has_key = __contains__
......@@ -19,17 +19,32 @@ from unittest import TestCase, main, makeSuite, TestSuite
from zope.testing.doctestunit import DocTestSuite
from zope.app.testing import placelesssetup
from test_icontainer import TestSampleContainer
from zope.app.container.btree import BTreeContainer
class TestBTreeContainer(TestSampleContainer, TestCase):
def makeTestObject(self):
from zope.app.container.btree import BTreeContainer
return BTreeContainer()
class TestBTreeLength(TestCase):
def testStoredLength(self):
#This is lazy for backward compatibility. If the len is not
#stored already we set it to the length of the underlying
#btree.
bc = BTreeContainer()
self.assertEqual(bc.__dict__['_BTreeContainer__len'](), 0)
del bc.__dict__['_BTreeContainer__len']
self.failIf(bc.__dict__.has_key('_BTreeContainer__len'))
bc['1'] = 1
self.assertEqual(len(bc), 1)
self.assertEqual(bc.__dict__['_BTreeContainer__len'](), 1)
def test_suite():
return TestSuite((
makeSuite(TestBTreeContainer),
makeSuite(TestBTreeLength),
DocTestSuite('zope.app.container.btree',
setUp=placelesssetup.setUp,
tearDown=placelesssetup.tearDown),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment