# -*- coding: utf-8
from SOAPpy import SOAPProxy
from SOAPpy import Types
from SOAPpy import Config
import re
import sys
import cElementTree
import random
url = "http://localhost:9090/waramuService/waramu"
namespace= "http://wssoap.waramu.htk.tlu.ee/"
username = ''
password = ''
c = Config
c.debug = 0
s = SOAPProxy(url, config=c)
out = open("dummy.php", "wb")
print >> out, "(.*?)', sessIdresponse).group(1))
if respCode: # not 0
msg = re.search('(.*?)', sessIdresponse).group(1)
print msg
sys.exit();
sessId = re.search('(.*?)', sessIdresponse).group(1)
# ======= list types
listTypesresponse = s._ns(namespace).listTypes(sessId = sessId)
xml = cElementTree.fromstring(listTypesresponse)
respCode = int(xml.find('status').text)
if respCode: # not 0
msg = xml.find('message').text
print "List types failed. Reason:",msg
xtypes = xml.find('types')
wtypes = {}
for t in xtypes:
tid = t.find('id').text
tname = t.find('name').text
wtypes[tid] = {'name': tname, 'fields':{} }
# ======= list type fields
fetched_voc = []
for w in wtypes.keys():
fieldsResponse = s._ns(namespace).describeType(sessId = sessId, typeId = w)
xml = cElementTree.fromstring(fieldsResponse)
respCode = int(xml.find('status').text)
if respCode: # not 0
msg = xml.find('message').text
print "Getting type description failed. Reason:", msg
continue
xfields = xml.find('description').find('fields')
for f in xfields:
wtypes[w]['fields'][f.get('name')] = {'multiLingual': f.get('multiLingual'), 'type': f.get('type')}
if f.text is not None:
print >> out, "/*translation:"+f.text+"*/"
print >> out, "elgg_echo(\"koolielu:"+f.get('name')+"\");"
print >> out, "/*translation:"+f.text+" helptext*/"
print >> out, "elgg_echo(\"koolielu:"+f.get('name')+"_helptext\")"
if f.get('fixedVocabulary') == "1" and f.get('name') not in fetched_voc:
fetched_voc.append(f.get('name'))
print "fetching vocabulary for:", f.get('name')
getVocabularyResponse = s._ns(namespace).getVocabulary(sessId = sessId, typeId = w, field = f.get('name'))
getVocabularyResponse = getVocabularyResponse.encode('utf-8')
xml = cElementTree.fromstring(getVocabularyResponse)
vocab = xml.find('vocabulary')
for voc in vocab:
e = voc.find('element')
if e.text is not None:
print >> out, "/*translation:"+e.text+"*/"
print >> out, "elgg_echo(\"koolielu:"+e.text+"\")"
print >> out, "/*translation:Files*/"
print >> out, "elgg_echo(\"koolielu:files\");"
print >> out, "/*translation:Files helptext*/"
print >> out, "elgg_echo(\"koolielu:files_helptext\")"
print >> out, "?>"
out.close()