chula.collection – Collection package

chula.data.base

Flexible collection that supports both dictionary and attribute style access.

class chula.collection.base.Collection

Example usage:

>>> from chula import collection
>>> person = collection.Collection()
>>> person.name = 'Mr. Smith'
>>> person.age = 20
>>> person.timezone = 'PST'
>>>
>>> print person.age
20
>>> print person['timezone']
PST
>>> print person
{'timezone': 'PST', 'age': 20, 'name': 'Mr. Smith'}
add(key, value)

Allow set via method

Parameters:
  • key (str) – Key to be set
  • value (Any) – Value of key
copy_into(collection)

Copy the current object into the object passed

Parameters:collection (chula.collection.Collection) – Object to be copied into
Return type:chula.collection.Collection (filled copy)
remove(key)

Allow list.remove() style attribute deletion

Parameters:key (str) – Key/value pair to be removed

chula.data.restricted

Collection with a configurable, but enforced number of attributes. This class is useful for situations where you you need to enforce every instance of the collection has the exact same structure.

class chula.collection.restricted.RestrictedCollection

Collection class with a pre-determined set of validkeys attributes

strip()

Purge privatekeys from the collection. This is useful when passing the collection along, without it’s private keys. This does actually delete the private keys, and thus acts on itself. If this isn’t what you want use copy.deepcopy().

chula.data.ubound

Collection that supports a configured maximum size. The size is enforced by purging records in a FIFO manner.

class chula.collection.ubound.UboundCollection(max)

Collection class with a maximum size

Table Of Contents

Previous topic

chula.cache – Wrapper module for upstream memcache.py

Next topic

chula.config – Configuration

This Page