[Python-Dev] winreg

Gordon McMillan gmcm@hypernet.com
Tue, 27 Jun 2000 06:36:07 -0400


Mark wrote:

[Paul]
> > I've just had a chance to look at the winreg module. I think
> > that it is too low-level.
> 
> I agree.  There was a proposal (from Thomas Heller, IIRC) to do
> just this. I successfully argued there should be _2_ modules for
> Python - the raw low-level API, which guarantees you can do
> (almost) anything.  A higher-level API could cover the 80% of
> cases.  It is probably worth getting in touch with Thomas - he
> may be able to dig up his proposed high-level API.  

Found it.

------- Forwarded message follows -------
From:           	"Thomas Heller" <thomas.heller@ion-
tof.com>
To:             	<python-dev@python.org>, <distutil-
sig@python.org>
Date sent:      	Thu, 3 Feb 2000 14:27:00 +0100
Subject:        	[Python-Dev] 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





_______________________________________________
Python-Dev maillist  -  Python-Dev@python.org
http://www.python.org/mailman/listinfo/python-dev
------- End of forwarded message -------

- Gordon