Package twisted :: Package persisted :: Module dirdbm :: Class Shelf |
[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
| ``__getitem__`(self, k)` `dirdbm[foo]` Get and unpickle the contents of a file in this directory.
| ``__setitem__`(self, k, v)` `shelf[foo] = bar` Create or modify a textfile in this directory.
Inherited from DirDBM
| ``__init__`(self, name)`
| ``__contains__`(self, key)` `key in dirdbm`
| ``__delitem__`(self, k)` `del dirdbm[foo]` Delete a file in this directory.
| ``__len__`(self)` Return the number of key/value pairs in this Shelf
| ``_decode`(self, k)` Decode a filename to get the key.
| ``_encode`(self, k)` Encode a key so it can be used as a filename.
| ``_readFile`(self, path)` Read in the contents of a file.
| ``_writeFile`(self, path, data)` Write data to a file.
| ``clear`(self)` Delete all key/value pairs in this dirdbm.
| ``close`(self)` Close this dbm: no-op, for dbm-style interface compliance.
`DirDBM` | ``copyTo`(self, path)` Copy the contents of this dirdbm to the dirdbm at `path`.
| ``get`(self, key, default)` Return the value associated with `key` or `default` if not `self.has_key(key)`
| ``getModificationTime`(self, key)` Returns modification time of an entry.
| ``has_key`(self, key)` Return a true value if this dirdbm has the specified key, a faluse value otherwise.
| ``items`(self)` Return a `list` of 2-tuples containing key/value pairs.
| ``keys`(self)` Return a `list` of filenames (keys).
| ``setdefault`(self, key, value)`
| ``update`(self, dict)` Add all the key/value pairs in `dict` to this dirdbm.
| ``values`(self)` Return a `list` of file-contents (values).

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 Overrides: `twisted.persisted.dirdbm.DirDBM.__getitem__`

### __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` Overrides: `twisted.persisted.dirdbm.DirDBM.__setitem__`

Generated by Epydoc 2.0 on Sat Oct 25 00:55:04 2003 | http://epydoc.sf.net