Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Add btrees in annotations

Project Description


Target audience

This is a package for integrators.

Installation and goal

Add collective.btrees to the eggs in your buildout. Add it to the zcml too, if you are on Plone 3.2 or lower. No need for further installation in the Plone UI.

This makes some small adapters available to store btrees in annotations on an object. There are adapters for all the btrees in the BTrees module. The adapters make the public methods of btrees available in the adapter. Use this when you want this and when you understand what this means. :-)

Example usage

Usually you will want to create an own adapter to override some settings, at least the key used to store the annotations. Put this in an

from zope.interface import implements
from zope.interface import Interface
from collective.btrees.interfaces import IOOBTreeContainer
from collective.btrees.adapters import OOBTreeContainer

class IFormValuesContainer(IOOBTreeContainer):

class FormValuesContainer(OOBTreeContainer):

    ANNO_KEY = 'my.package.formvalues'

    def _check_key(self, key):
        if not isinstance(key, basestring):
            raise TypeError("base string expected as key")

    def _check_value(self, value):
        if not isinstance(value, dict):
            raise TypeError("dictionary expected as value")

Register the adapter in zcml:


Use it within for example a browser view to store the request form dictionary in the btree (if this for some reason makes sense for your website):

container = IFormValuesContainer(self.context)
key = 'my key'  # maybe use the user id as key
value = self.request.form
container.insert(key, value)
container.get(key)  # will return value


I have tried this on Plone 3.3 and 4.1. It will likely work on other versions as well.


Maurits van Rees


1.1 (2012-06-05)

  • Changed url to point to the github collective. [maurits]

1.0 (2012-05-16)

  • Initial release [maurits]
Release History

Release History

This version
History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date (15.1 kB) Copy SHA256 Checksum SHA256 Source Jun 5, 2012

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting