Connected to mydb in PostgreSQL:
mydb=# CREATE FUNCTION file_test () RETURNS text AS $$
if open('mydir/myfile.xsl'): return 'success'
$$ LANGUAGE plpythonu;
CREATE FUNCTION
mydb=# SELECT file_test();
ERROR: IOError: [Errno 2] No such file or directory: 'mydir/myfile.xsl'
CONTEXT: Traceback (most recent call last):
PL/Python function "file_test", line 2, in <module>
if open('mydir/myfile.xsl'): return 'success'
PL/Python function "file_test"
Over to Python:
>>> if open('mydir/myfile.xsl'): print 'success'
...
success
>>>
An absolute path didn't seem to help PL/Python. What I'd like to do is use Postgres's query_to_xml() and run an XSLT transformation on the return. But to do that I'll need to read the xsl file...