Mailing List Archive

Revised proposal (and preliminary implementation): Registry access module for Python on Windows
Ok, at least the first proposal did start the discussion.
Here is a revised one:

A preliminary implementation is available at
http://starship.python.net/crew/theller/

----------------------------------------------------------------------
winreg - windows registry access module

Exception:
error - raised when a function fails. Will contain
a windows error code and a textual description.

Objects:
regnode object - represents a open key in the
registry.

Functions:
OpenKey (name) -> regnode object
Opens an existing key with the specified access rights
and returns a regnode object.
name is specified like "HKLM\Software\Python"
or "HKEY_LOCAL_MACHINE\Software\Python"

CreateKey (name) -> regnode object
Creates a new key or opens an existing one
and returns a regnode object.
For the name format see OpenKey

regnode object methods:
Values () -> dict
Returns a dictionary mapping names to values.
The <default> or unnamed value has the key ''.
The values are either strings or integers, depending
on the REG_* type.

GetValue ([name]) -> integer or string
Returns a value specified by name or the default value.

SetValue ([name,] value)
Set a named or the <default> value.
Named values must be integers or string (which are stored
as REG_DWORD or REG_SZ).
Should an optional third parameter be used, allowing to
store in other REG_* typecodes? I dont think so.

DeleteValue ([name])
Deletes a named or the <default> value.

SubKeys () -> sequence
Returns a sequence containing the names of all subkeys.

DeleteKey (name [,recursive=0])
If recursive is 0, deletes the named key if no subkeys exist.
If there are subkeys an error is raised.
If recursive is not 0, the named key is deleted
including subkeys.

OpenKey (name) -> regnode object
Openes an existing subkey and returns a regnode
object pointing to it.

CreateKey (name) -> regnode object
Creates a new or openes an existing subkey and
returns a regnode object pointing to it.

regnode objects have the following properties:
name - the name of the RegistryKey, something
like "HKLM\Software\Python"
hkey - the integer keyhandle

----------------------------------------------------------------------

Thomas Heller