Jython - problem import os

2007-08-08 Thread nmin
Hi.

I'm using Jython in combination with Java, webservices and jboss4.0.4.

The webservice is implemented in java and creates an PythonInterpreter
object which loads the jython scripts.
I wrote an jython script which uses a function from another jython
file called library.py.

So, i wrote:

service.java


public void webMethod(){
PythonInterpreter p = new PythonInterpreter()

p.execfile(skript.py)
}

skript.py
==
from library import *

test=testFunction()

library.py
===

import os

def testFunction():
os.getcwd()


...all these files are inside my ear-archive and the service.java
represent my webservice class.
So, calling WebMethod returns:

ImportError: no module named javaos in library.py.

Any ideas?

-- 
http://mail.python.org/mailman/listinfo/python-list


Jython - variables are stored somehow

2007-08-09 Thread nmin
Hi,

I'm using Jython in combination with java.

I wrote a jython skript, which calls a function from another jython
module called library.py.

So, executing the function genData() in skript .py runs without
problem but if I execute the same function again, the data from the
first run is stored somehow and is added to the new data.

So, if you look at the result:
#1 in DatenTypen.py return an empty list each time the program runs.
Ok ... clear so far
#2 in library.py returns an empty list, when the program runs for the
first time ... but when the function is
called again, the list contains an element. Each time you call the
function again, one element is added!
Why??  out.abschnitte should be the same as printed in #1 or not?

Here is the code:

skript.py
==
from library import *

def genData():

 
out=DMS_sendFiles_ein_Abschnitt([["testdata1.test","testdata2.test","testdata3.test"]])

return out

library.py
===
from DatenTypen import AusgangsDatenDeichMonitor
from DatenTypen import DMS_Abschnitt
from DatenTypen import DMS_GeoData
from DatenTypen import DMS_GeoDataFile

def DMS_sendFiles_ein_Abschnitt(filelist):

out=AusgangsDatenDeichMonitor()

print "out.abschnitte: "+str(out.abschnitte) #2

abschnitt=DMS_Abschnitt()

for f in filelist:
data=DMS_GeoData()

for layer in f:

datalayer=DMS_GeoDataFile()

datalayer.dateiname=layer

datalayer.dateiinhalt="TEST"

data.layerFiles.append(datalayer)

abschnitt.bildSequenze.append(data)

out.abschnitte.append(abschnitt)

return out

DatenTypen.py
===

class AusgangsDatenDeichMonitor:

abschnitte=[]

def __init__(self):
abschnitte=[]
print "Abschnitt in DatenTypen: "+str(abschnitte) #1

class DMS_Abschnitt:

bildSequenze=[]

def __init__(self):
abschnittsNummer=0
bildSequenze=[]

class DMS_GeoData:

layerFiles=[]

def __init__(self):
layerFiles=[]

class DMS_GeoDataFile:

dateiinhalt="dateiinhalt"

dateiname="dateiname"

zipped=False

def __init__(self):
dateiinhalt="dateiinhalt"
dateiname="dateiname"
zipped=False

So, I read about deleting Instances with "del" ... but it does not
work at all.

Any Ideas?

Thanks  in advance

Simon

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jython - variables are stored somehow

2007-08-14 Thread nmin
works perfect ... thanks a lot!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jython - problem import os

2007-08-14 Thread nmin
Thats it ...

Additionally I had to set the python path with sys.path.append to the
Lib folder .. and now it works perfect.

thanks a lot

Simon

-- 
http://mail.python.org/mailman/listinfo/python-list