[Tutor] implementing config files

Carroll, Barry Barry.Carroll at psc.com
Fri Jun 2 19:45:17 CEST 2006


Carlos:

Where does one find the objxml module?  I have looked on python.org and
Google and can't find it.  

Thanks in advance,
 
Barry
barry.carroll at psc.com
541-302-1107
________________________
We who cut mere stones must always be envisioning cathedrals.

-Quarry worker's creed

> -----Original Message-----
> Date: Thu, 1 Jun 2006 23:36:27 -0700
> From: "Carlos Daniel Ruvalcaba Valenzuela" <clsdaniel at gmail.com>
> Subject: Re: [Tutor] implementing config files
> To: "Tracy R Reed" <treed at ultraviolet.org>
> Cc: tutor at python.org
> Message-ID:
> 	<4fae7dfa0606012336k1999a7e7w3c5a290b4d413272 at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> Your could try to use XML files to store configuration files, I
> already coded something like that, using expat parser and loading the
> XML contents to objects and attributes, this is a sample code of how
> works my module:
> 
> Lets supouse we have this file config.xml with the following contents:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <config>
>         <connection>
>                 <server>MySQL</server>
>                 <host>localhost</host>
>                 <port>21</port>
>                 <user>username</user>
>                 <passwd></passwd>
>         </connection>
> </config>
> 
> and in our code:
> 
> from objxml import *
> 
> fd = file('config.xml', 'r')
> p = XMLParser(fd)
> 
> root = p.Root
> port = str(root.connection.port)
> user = str(root.connection.username)
> 
> All nodes are objects, converting them to strings gets you the
> content, you can also access the atributes as normal object
> attributes.
> 
> This code can be useful for what you want, take a look.
> 
> Regards
> Carlos Daniel Ruvalcaba Valenzuela
> 
> 
> On 6/1/06, Tracy R Reed <treed at ultraviolet.org> wrote:
> > Hello all!
> >
> > I am writing some code to implement a bunch of passive checks for
the
> > nagios network monitoring system. 
<<snip>>
> >
> > --
> > Tracy R Reed                  http://ultraviolet.org
> > A: Because we read from top to bottom, left to right
> > Q: Why should I start my reply below the quoted text



More information about the Tutor mailing list