source: TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/insecure.py @ 765

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/insecure.py@765
Revision 765, 1.4 KB checked in by lawrence, 14 years ago (diff)

This version of the browse portal simply gets the stub-b
document and shows it to the user. No security. No xslt
transformation.

Line 
1#
2#This module provides python wrappers to Kevin's java code
3# I'm aiming to avoid having any java dependencies in the main browseCGI code
4# as I figure these command line activities at some point ought to be removed.
5# They certainly should be regarded as potentially insecure, especially the
6# exist call ...
7# BNL, April 2006
8#
9
10import os, os.path
11xalanCLASSPATH='wherever'
12def jarLoc():
13        #don't want the jar in the cgi directory ... not quite sure why, but
14        #it seems wrong ...
15        cwd=os.getcwd()
16        returnMolesJar='./returnmoles.jar'
17        return os.path.normpath(os.path.join(cwd,returnMolesJar))
18
19def insecureGetDoc(uri):
20        ''' Use Kevin's code to get the document from exist '''
21        #we assume the URI is of the form repository/localid
22        #we don't use os.path.split, because this is os indpendent.
23        try:
24                repPath,localID=uri.split('/')
25        except:
26                return 'Invalid URI'
27        else:
28                returnMolesJar=jarLoc()
29                cmd='java -jar %s %s %s xmldb:exist://glue.badc.rl.ac.uk:8080/exist/xmlrpc'%(
30                returnMolesJar,repPath,localID)
31                try:
32                        stdin,stdout,stderr=os.popen3(cmd)
33                except:
34                        return 'Unable to Obtain Document'
35                error=stderr.readlines()
36                if error!=[]:
37                        #return returnMolesJar
38                        return error
39                else:
40                        return stdout.readlines()
41       
42def doXSLT (document,xsltMethod):
43        ''' Handle a possibly external transformation to produce an html page '''
44        return '<p> [[[%s]]]</p>'%document
45       
46if __name__=="__main__":
47        print insecureGetDoc('badc.nerc.ac.uk/dataent13')
Note: See TracBrowser for help on using the repository browser.