Can anyone explain what is happening here. I am using Saxon to transform
an xml file(source) using a stylesheet(style) the result is then written
to Postgres. The contents of source are uploaded in Zope and passed to
the external method as a string. When I run this external method:

import psycopg, string, re, subprocess
def scholarpack_xml_transform(source):
    f=open('/opt/scholarpack/ancillary/source.xml','w')
    f.write(source) 
    f.close
    source= '/opt/scholarpack/ancillary/source.xml'
    style='/opt/scholarpack/ancillary/style.xml'
    source1=source.replace(''','`')
    source2=source1.replace('NLPGaddress','BS7666address')
    p=re.compile("\'")
    source3=p.sub( '`' , source2)
    r = 
subprocess.Popen(['/opt/scholarpack/ancillary/jre/bin/java','-jar','./saxon.jar',source3,style],
 stdout = subprocess.PIPE,cwd = '/opt/scholarpack/ancillary/')
    r.wait()
    transformed = r.stdout.read()
    transformed1=transformed.replace(',)',')')
    conn = psycopg.connect("dbname=scholarpack user=scholarpack")
    curs = conn.cursor()
    do=curs.execute(transformed1)
    do
    conn.commit()
    conn.close
    
I get a programming error thrown from the conn.commit() line and the
method fails. However when I run the following script externally to Zope
after the Zope failure (so that source.xml exists) the DB write is
successful.

#!/opt/scholarpack/python/bin/python
import psycopg, string, re, subprocess
source='source.xml'
style='style.xml'
source1=source.replace(''','`')
source2=source1.replace('NLPGaddress','BS7666address')
p=re.compile("\'")
source3=p.sub( '`' , source2)
r = 
subprocess.Popen(['/opt/scholarpack/ancillary/jre/bin/java','-jar','./saxon.jar',source3,style],
 stdout = subprocess.PIPE,cwd = '/opt/scholarpack/ancillary/')
r.wait()
transformed = r.stdout.read()
transformed1=transformed.replace(',)',')')
conn = psycopg.connect("dbname=scholarpack user=scholarpack")
curs = conn.cursor()
do=curs.execute(transformed1)
do
conn.commit()
conn.close

Can anyone point me in the correct direction?
regards
garry
    

_______________________________________________
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to