The ConfigParser class was added in Python 2.3 and the SafeConfigParser 
class was added in Python 2.4 (so in your Python terminal, you must be 
using Python V2.4 or later).  However, you're using STAX V3.4.5 or earlier 
which uses Jython 2.1 to execute Python code.  Jython 2.1 is based on 
Python 2.1 so these classes are not available in Jython 2.1.  Note that 
Jython development lags behind Python.  The STAX User's Guide talks about 
differences between Jython and Python in "Appendix F: Jython and CPython 
Differences" in the STAX User's Guide at 
http://staf.sourceforge.net/current/STAX/staxug.html#Header_CPythonDiffs.

In March 2011, Jython 2.5.2 was finally released (based on Python 2.5.2). 
We released STAX V3.5.0 Beta 1 (available at 
http://staf.sourceforge.net/getstax.php) and it supports using Jython 
2.5.2.  So you could try it out.

The latest releases of the STAX service are:
 
STAX Version 3.4.5: Latest official release. Uses Jython 2.1. 

STAX Version 3.5.0 Beta 1: Beta release. The purpose of this Beta is to 
provide support for Jython 2.5.2 (instead of Jython 2.1 which is what is 
supported by previous STAX versions). The final Jython 2.5.2 version was 
released in March 2011. However, we don't have approval to distribute the 
final Jython 2.5.2 version yet, so the STAX service jar file provided by 
it does not contain Jython 2.5.2. You need to download Jython 2.5.2 via 
the Jython website and install it and then run the provided 
STAXJarUpdateForJython252 Java application to create a STAX.jar file to 
use for registering the STAX V3.5.0 Beta 1 service. Follow the 
instructions for how to do this in the Installation and Configuration 
section for the STAX Service Machine in the STAX V3.5.0 Beta 1 User's 
Guide. 

Once we have approval to distribute Jython 2.5.2, we will release STAX 
Version 3.5.0 which will contain Jython 2.5.2. 

[staf-users] import python module - issue
From: Raja Narayanan <v_rajnarayan@re...> - 2011-04-20 17:22 

I'm trying to parse a configuration file using the following python code 
in STAX XML program:


from ConfigParser import SafeConfigParser

import glob

parser = SafeConfigParser()

parser.read('/usr/local/staf/services/stax/samples/config.txt')

remoteclient = parser.get('globalvariable', 'remoteclient')


When attempt to run the code through STAX xml program. It fails to run 
showing the python error code "importerror: Cannot import name 
SafeConfigParser".


Note: When run the same code through Python terminal, everything works 
fine.

Please suggest on this.

--------------------------------------------------------------
Sharon Lucas
IBM Austin,   luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313
------------------------------------------------------------------------------
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
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to