>From: Victor Hooi
>Sent: Tue, April 19, 2011 1:21:34 AM
>

Victor -

> We have an application with it's configuration stored across a
> number of XML files.
> 
> Currently, I'm finding generateDS incredibly useful for processing
> and working with the .XSD schema files =).
> 
> My question is - I was thinking of writing a GUI wrapper to edit the
> XML configuration files. Since it's Python, PyQT seemed like a
> natural fit for a GUI toolkit for this.
> 
> Do you perhaps have any advice or experience to share on this? Or
> know of anybody who did something similar? Shortcuts?
> 
> It seems like a fairly common use-case - however I'm not quite sure
> how I should design a PyQT GUI using the generateDS output, that's
> generic and introspecty enough, without hardcoding in the
> structure/semantics of the XML file? Any help at all is greatly
> appreciated.

Sounds like an appropriate use case for the use of generateDS.py.

You might want to think of generateDS.py, once you have generated
bindings (Python classes), helps you do the following:

1. Read and parse an XML instance document, creating a tree of
   instances of (generated) Python classes.

2. Extract data items from the tree.

3. Insert data items into the tree.

4. Serialize the tree to a string, or write (export) the tree to a
   file (an XML instance doc).

It seems to me that it's likely that these are kinds of assistance
you'll want.

The choice of GUI toolkit is up to you.  PyQT, WxPython, and
PyGTK/glade are all appropriate, depending on what you feel best
working with and what would be appropriate to install on your users'
machines.  All generateDS.py is doing is generating a
module/library that you can import and use in you GUI (or other
application) to access the configuration data.

By the way, the generateDS.py distribution contains a GUI
application, generateds_gui.py, written with PyGTK and glade.  There
is currently a problem with that application: the current version of
the Gtk library is missing a feature that I depended on when I
implemented generateds_gui.py using an earlier version of the Gtk
libraries, so currently you can define and save a session file, but
cannot read/load a session file.

Anyway, a session file is, from your point of view, basically a
configuration.  And, generateds_gui.py uses a small module/library
that I generated with generateDS.py to read, extract items from,
update, and write out an XML file.

The only advice I can give you about trying to avoid hard code
access to each different configuration file might be this -- If you
have or think you will have a need to do configuration on different
configuration files, then you might think about extracting from XML
to a flat file format or to an array in memory that has a common
format.

1. Extract to and from CSV format files or some other flat file
   format.  generateDS.py is a good tool for this transformation.
   Or, you could even use XSL-T.

2. Write your GUI application using this more uniform, common data
   format, either one in memory or one from a file.

With respect to hard coding, the current problem in
generateds_gui.py has to do with a "trick" I used to avoid having to
write code (hard coding?) specific to each different value within a
session.  Recent versions of PyGtk dropped support for access to the
names of GUI objects, and I had relied on that.  So, you'd have to
be careful about that if you use PyGtk.  But, other than that, I
thought that PyGtk plus glade was a good toolkit.

Hope this helps.  Let me know if I can answer additional questions.

- Dave



 -- 


Dave Kuhlman
http://www.rexx.com/~dkuhlman

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to