Package WebStack :: Package Repositories :: Module Directory :: Class DirectoryRepository
[show private | hide private]
[frames | no frames]

Class DirectoryRepository


A directory repository providing session-like access to files.

Method Summary
  __init__(self, path, fsencoding, delay)
Initialise the repository using the given 'path' to indicate the location of the repository.
  __delitem__(self, key)
Remove the file associated with the given 'key'.
  __getitem__(self, key)
Return the contents of the file associated with the given 'key'.
  __setitem__(self, key, value)
Set the contents of the file associated with the given 'key' using the given 'value'.
  edit_path(self, key)
Return the full path to the 'key' in the filesystem provided that the file associated with the 'key' is locked for editing.
  full_path(self, key, edit)
Return the full path to the 'key' in the filesystem.
  has_key(self, key)
Return whether a file with the name specified by 'key is stored in the repository.
  items(self)
Return a list of (name, value) tuples for the files stored in the repository.
  keys(self)
Return the names of the files stored in the repository.
  lock(self, key, create, opener)
Lock the file associated with the given 'key'.
  unlock(self, key)
Unlock the file associated with the given 'key'.
  values(self)
Return the contents of the files stored in the repository.
  _convert_fsname(self, name)
Convert the given 'name' as a plain string in the filesystem encoding to a Unicode object.
  _convert_name(self, name)
Convert the given 'name' to a plain string in the filesystem encoding.

Class Variable Summary
str new_filename = '__new__'

Method Details

__init__(self, path, fsencoding=None, delay=1)
(Constructor)

Initialise the repository using the given 'path' to indicate the
location of the repository. If no such location exists in the filesystem
an attempt will be made to create the directory.

The optional 'fsencoding' parameter can be used to assert a particular
character encoding used by the filesystem to represent filenames. By
default, the default encoding is detected (or Unicode objects are used
if appropriate).

The optional 'delay' argument specifies the time in seconds between each
poll of an opened repository file when that file is found to be locked
for editing.

__delitem__(self, key)
(Index deletion operator)

Remove the file associated with the given 'key'.

__getitem__(self, key)
(Indexing operator)

Return the contents of the file associated with the given 'key'.

__setitem__(self, key, value)
(Index assignment operator)

Set the contents of the file associated with the given 'key' using the
given 'value'.

edit_path(self, key)

Return the full path to the 'key' in the filesystem provided that the
file associated with the 'key' is locked for editing.

full_path(self, key, edit=0)

Return the full path to the 'key' in the filesystem. If the optional
'edit' parameter is set to a true value, the returned path will refer to
the editable version of the file.

has_key(self, key)

Return whether a file with the name specified by 'key is stored in the
repository.

items(self)

Return a list of (name, value) tuples for the files stored in the
repository.

keys(self)

Return the names of the files stored in the repository.

lock(self, key, create=0, opener=None)

Lock the file associated with the given 'key'. If the optional 'create'
parameter is set to a true value (unlike the default), the file will be
created if it did not already exist; otherwise, a KeyError will be
raised.

If the optional 'opener' parameter is specified, it will be used to
create any new file in the case where 'create' is set to a true value;
otherwise, the standard 'open' function will be used to create the file.

Return the full path to the editable file.

unlock(self, key)

Unlock the file associated with the given 'key'.

Important note: this method should be used in a finally clause in order
to avoid files being locked and never being unlocked by the same process
because an unhandled exception was raised.

values(self)

Return the contents of the files stored in the repository.

_convert_fsname(self, name)

Convert the given 'name' as a plain string in the filesystem encoding to
a Unicode object.

_convert_name(self, name)

Convert the given 'name' to a plain string in the filesystem encoding.

Class Variable Details

new_filename

Type:
str
Value:
'__new__'                                                              

Generated by Epydoc 2.1 on Thu Mar 1 00:37:14 2007 http://epydoc.sf.net