Registry / database / Products.BTreeFolder2

Products.BTreeFolder2

JSON →
library6.0pypypi✓ verified 84d ago

A BTree-based implementation for Zope's Object Folder (OFS). This product replaces the standard OFS Folder with a scalable, BTree-backed folder that can handle large numbers of objects without performance degradation. Current version 6.0 supports Python >=3.10 and requires Zope 5 / Zope 6 environment. Releases follow Zope release cycle, generally stable.

pip install Products.BTreeFolder2
INSTALL
IMPORT
SIG · PRODUCTS.BTREEFOLD
P
Products.BTreeFolder2
databasepythonv6.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BTreeFolder2
from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2
from Products.BTreeFolder2 import BTreeFolder2
BTreeFolder2 is not directly in __init__.py; it is in the BTreeFolder2 module within the package.
manage_addBTreeFolder
from Products.BTreeFolder2.BTreeFolder2 import manage_addBTreeFolder
from Products.BTreeFolder2 import manage_addBTreeFolder
Same as above: the function is in the submodule.

Demonstrates both the typical Zope management function and a minimal ZODB-based test setup. Note that BTreeFolder2 is intended to be used within a Zope application server; standalone usage may require additional setup.

from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2, manage_addBTreeFolder # In a Zope product or script: # Assume 'container' is an OFS Folder or similar # btf = manage_addBTreeFolder(container, 'myBTreeFolder', 'My BTree Folder') # The above works if called within Zope context (e.g., in a Python Script or through ZMI). # Alternatively, to instantiate directly (requires Zope environment): from ZODB.DemoStorage import DemoStorage from ZODB import DB import transaction storage = DemoStorage() db = DB(storage) conn = db.open() root = conn.root() # Create a BTreeFolder2 in the root folder = BTreeFolder2('folder_id').__of__(root) root['folder_id'] = folder print('Created BTreeFolder2 with id', folder.getId()) transaction.commit()
Debug
Known issues
breakingVersion 6.0 drops support for Python versions below 3.10. If you are on Python 2.7 or 3.8, pin to an older release (e.g., 5.1).
fix
Upgrade to Python >=3.10 or use Products.BTreeFolder2<6.0.
affects: 6.0
gotchaBTreeFolder2 is not a direct replacement for OFS.Folder. Zope management interfaces (like the ZMI) may not display BTreeFolder2 contents correctly if your site uses custom templates that rely on standard folder ordering.
fix
Ensure custom ZMI templates handle BTreeFolder2. Use .items() properly; BTreeFolder2 returns items in BTree order (sorted by key).
affects: all
deprecatedThe alias 'Products.BTreeFolder2.BTreeFolder2.manage_addBTreeFolder' is deprecated; use the direct path from the same module.
fix
Update imports to 'from Products.BTreeFolder2.BTreeFolder2 import manage_addBTreeFolder'.
affects: 5.x and earlier
gotchaDo not use BTreeFolder2 outside a ZODB connection. The object is meant to be stored in a ZODB; attempting to create it without a connection leads to errors like 'AttributeError: __parent__'.
fix
Always create BTreeFolder2 instances within a ZODB transaction context, typically using manage_add* or by wrapping with __of__.
affects: all
Errors
Common errors & fixes
AttributeError: module 'Products.BTreeFolder2' has no attribute 'BTreeFolder2'
Wrong import path. BTreeFolder2 class is not in __init__.py but in submodule.
fix
Use 'from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2'.
TypeError: __init__() missing 1 required positional argument: 'id'
BTreeFolder2 constructor requires an 'id' argument (and optionally 'title') but was called without it.
fix
Pass the id: BTreeFolder2('myfolder')
AttributeError: 'BTreeFolder2' object has no attribute 'manage_addProduct'
BTreeFolder2 does not have 'manage_addProduct'; that's a method of Zope's FolderManager. Trying to add a product incorrectly.
fix
Use manage_addBTreeFolder from the module, or use the ZMI to add a BTreeFolder2 product.
Upgrade
Version history
6.0latest on PyPI · released Nov 19, 2025
Audit
Dependencies
ZoperequiredBTreeFolder2 is a Zope product; requires Zope framework to be installed (usually in a Zope instance).
BTreerequiredUses ZODB BTree implementation from ZODB or BTrees package.
Agent activity
49 hits · last 30 days
node
42
OpenAI (training)
2
Resources
Products.BTreeFolder2 — pip install Products.BTreeFolder2 · libregistry