Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install collective.btrees

How to install collective.btrees

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install collective.btrees
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.1 Available View build log
1.0 Available View build log
Windows (64-bit)
1.0
1.1Never BuiltWhy not?
1.0 Available View build log
Mac OS X (10.5+)
1.1 Available View build log
1.0 Available View build log
Linux (32-bit)
1.1 Available View build log
1.0 Available View build log
Linux (64-bit)
1.1 Available View build log
1.0 Available View build log
 
License
GPL
Dependencies
Lastest release
version 1.1 on Jun 7th, 2012

Documentation

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 adapters.py:

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):
    pass

class FormValuesContainer(OOBTreeContainer):

    implements(IFormValuesContainer)
    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:

<adapter
    for="zope.interface.Interface"
    provides=".adapters.IFormValuesContainer"
    factory=".adapters.FormValuesContainer"
    />

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
Compatibility

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

Authors

Maurits van Rees

Changelog

1.1 (2012-06-05)
  • Changed setup.py url to point to the github collective. [maurits]
1.0 (2012-05-16)
  • Initial release [maurits]

Subscribe to package updates

Last updated Jun 7th, 2012

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.