twisted.persisted.dirdbm.DirDBM
class documentationtwisted.persisted.dirdbm
View Source
(View In Hierarchy)
Known subclasses: twisted.persisted.dirdbm.Shelf
A directory with a DBM interface.
This class presents a hash-like interface to a directory of small, flat files. It can only use strings as keys or values.
Method | __init__ | |
Method | __len__ | |
Method | __setitem__ | dirdbm[k] = v Create or modify a textfile in this
directory |
Method | __getitem__ | dirdbm[k] Get the contents of a file in this directory as a
string. |
Method | __delitem__ | del dirdbm[foo] Delete a file in this directory. |
Method | keys | |
Method | values | |
Method | items | |
Method | has_key | |
Method | setdefault | |
Method | get | |
Method | __contains__ | key in dirdbm |
Method | update | Add all the key/value pairs in dict to this dirdbm. Any
conflicting keys will be overwritten with the values from
dict . |
Method | copyTo | Copy the contents of this dirdbm to the dirdbm at path . |
Method | clear | Delete all key/value pairs in this dirdbm. |
Method | close | Close this dbm: no-op, for dbm-style interface compliance. |
Method | getModificationTime | Returns modification time of an entry. |
Method | _encode | Encode a key so it can be used as a filename. |
Method | _decode | Decode a filename to get the key. |
Method | _readFile | Read in the contents of a file. |
Method | _writeFile | Write data to a file. |
Parameters | name | Base path to use for the directory storage. (type: str) |
Read in the contents of a file.
Override in subclasses to e.g. provide transparently encrypted dirdbm.
Write data to a file.
Override in subclasses to e.g. provide transparently encrypted dirdbm.
dirdbm[k] = v
Create or modify a textfile in this
directory
Parameters | k | key to set (type: str) |
v | value to associate with k (type: str) |
dirdbm[k]
Get the contents of a file in this directory as a
string.
Parameters | k | key to lookup (type: str) |
Returns | The value associated with k | |
Raises | KeyError | Raised when there is no such key |
del dirdbm[foo]
Delete a file in this directory.
Parameters | k | key to delete (type: str) |
Raises | KeyError | Raised when there is no such key |
Parameters | key | The key to test (type: str) |
Returns | A true value if this dirdbm has the specified key, a faluse value otherwise. |
Parameters | key | The key to lookup (type: str) |
value | The value to associate with key if key is not already associated with a value. |
Parameters | key | The key to lookup (type: str) |
default | The value to return if the given key does not exist | |
Returns | The value associated with key or default if not
self.has_key(key) |
key in dirdbm
Parameters | key | The key to test (type: str) |
Returns | A true value if self.has_key(key) , a false value otherwise. |
Add all the key/value pairs in dict
to this dirdbm. Any
conflicting keys will be overwritten with the values from
dict
.
Parameters | dict | A mapping of key/value pairs to add to this dirdbm. (type: mapping) |
Copy the contents of this dirdbm to the dirdbm at path
.
Parameters | path | The path of the dirdbm to copy to. If a dirdbm exists at the destination
path, it is cleared first. (type: str ) |
Returns | The dirdbm this dirdbm was copied to. (type: DirDBM ) |
Returns modification time of an entry.
Returns | Last modification date (seconds since epoch) of entry key | |
Raises | KeyError | Raised when there is no such key |