Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zope-container
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
zope-container
Commits
4e778be2
Commit
4e778be2
authored
Jun 29, 2007
by
Bernd Dorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new bootstrap, store length in btree containers, version bump to 3.5
parent
dcc461b9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
10 deletions
+72
-10
CHANGES.txt
CHANGES.txt
+11
-2
bootstrap.py
bootstrap.py
+9
-5
setup.py
setup.py
+1
-1
src/zope/app/container/btree.py
src/zope/app/container/btree.py
+35
-1
src/zope/app/container/tests/test_btree.py
src/zope/app/container/tests/test_btree.py
+16
-1
No files found.
CHANGES.txt
View file @
4e778be2
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.
bootstrap.py
View file @
4e778be2
...
...
@@ -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
)
setup.py
View file @
4e778be2
...
...
@@ -21,7 +21,7 @@ import os
from
setuptools
import
setup
,
find_packages
,
Extension
setup
(
name
=
'zope.app.container'
,
version
=
'3.
4.0b
1'
,
version
=
'3.
5.0a
1'
,
url
=
'http://svn.zope.org/zope.app.container'
,
license
=
'ZPL 2.1'
,
description
=
'Zope container'
,
...
...
src/zope/app/container/btree.py
View file @
4e778be2
...
...
@@ -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__
src/zope/app/container/tests/test_btree.py
View file @
4e778be2
...
...
@@ -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
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment