Package twisted :: Package persisted :: Module dirdbm :: Class Shelf

[show private | hide private]
[frames | no frames]

## Class Shelf

    DirDBM --+
             |
            Shelf

A directory with a DBM shelf interface.

This class presents a hash-like interface to a directory of small, flat files. Keys must be strings, but values can be any given object.

Method Summary
| ``__init__`(self, name)` (inherited from `DirDBM`)
| ``__contains__`(self, key)` `key in dirdbm` (inherited from `DirDBM`)
| ``__delitem__`(self, k)` `del dirdbm[foo]`Delete a file in this directory. (inherited from `DirDBM`)
| ``__getitem__`(self, k)` `dirdbm[foo]`Get and unpickle the contents of a file in this directory.
| ``__len__`(self)` Return the number of key/value pairs in this Shelf (inherited from `DirDBM`)
| ``__setitem__`(self, k, v)` `shelf[foo] = bar`Create or modify a textfile in this directory.
| ``clear`(self)` Delete all key/value pairs in this dirdbm. (inherited from `DirDBM`)
| ``close`(self)` Close this dbm: no-op, for dbm-style interface compliance. (inherited from `DirDBM`)
`DirDBM` | ``copyTo`(self, path)` Copy the contents of this dirdbm to the dirdbm at `path`. (inherited from `DirDBM`)
| ``get`(self, key, default)` Return the value associated with `key` or `default` if not `self.has_key(key)` (inherited from `DirDBM`)
| ``getModificationTime`(self, key)` Returns modification time of an entry. (inherited from `DirDBM`)
| ``has_key`(self, key)` Return a true value if this dirdbm has the specified key, a faluse value otherwise. (inherited from `DirDBM`)
| ``items`(self)` Return a `list`of 2-tuples containing key/value pairs. (inherited from `DirDBM`)
| ``keys`(self)` Return a `list`of filenames (keys). (inherited from `DirDBM`)
| ``setdefault`(self, key, value)` (inherited from `DirDBM`)
| ``update`(self, dict)` Add all the key/value pairs in `dict`to this dirdbm. (inherited from `DirDBM`)
| ``values`(self)` Return a `list`of file-contents (values). (inherited from `DirDBM`)

Method Details

### __getitem__(self, k)
(Indexing operator)

`dirdbm[foo]` Get and unpickle the contents of a file in this directory.

  Parameters:
    `k` - The key to lookup
    (type=str)
  Returns:
    The value associated with the given key
  Raises:
    `KeyError` - Raised if the given key does not exist

### __setitem__(self, k, v)
(Index assignment operator)

`shelf[foo] = bar` Create or modify a textfile in this directory.

  Parameters:
    `k` - The key to set
    (type=str)
    `v` - The value to associate with `key`

Generated by Epydoc 1.1 on Thu May 8 13:16:34 2003 | http://epydoc.sf.net