Hi Folks,

 

Having a very strange problem in using python with apache/mod_python. 

 

[conf.py attached]

>>> from ast.conf import conf
>>> c = conf()
>>> a = c.readPath('sandbox')
>>>  len (a)

>>>  30

 

The same code when run thru the a web script gives following error -

>>>> 

[Errno 13] Permission denied: '/home/ast/ast-linux.conf'

 
Mod_python error: "PythonHandler mod_python.publisher"
 
Traceback (most recent call last):
 
  File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in
HandlerDispatch
    result = object(req)
 
  File "/usr/lib/python2.4/site-packages/mod_python/publisher.py", line 213,
in handler
    published = publish_object(req, object)
 
  File "/usr/lib/python2.4/site-packages/mod_python/publisher.py", line 412,
in publish_object
    return publish_object(req,util.apply_fs_data(object, req.form, req=req))
 
  File "/usr/lib/python2.4/site-packages/mod_python/util.py", line 439, in
apply_fs_data
    return object(**args)
 
  File "/var/www/html/ast-sandbox/testConf.py", line 9, in index
    path = c.readPath('sandbox')
 
  File "/usr/lib/python2.4/ast/conf.py", line 40, in readPath
    self.vars = self.conf.options(target)
 
  File "/usr/lib/python2.4/ConfigParser.py", line 241, in options
    raise NoSectionError(section)
 
NoSectionError: No section: 'sandbox'

>>>>> 

 

WebScript -

----

import sys

from ast.conf import conf

 

def index(req, **kw):

    sys.stdout = req

    req.content_type = 'text/html'

 

    c = conf()

    path = c.readPath('sandbox')

    print path

----

 

The configuration file is the standard format used by ConfigParser module.

 

The permission for the ast-linux.conf file is the same as the user/group
defined in httpd.conf.

 

[EMAIL PROTECTED] ast-sandbox]# ls -l /home/ast/ast-linux.conf

-rw-rw-rw- 1 777 ast 7936 Jun 21 11:11 /home/ast/ast-linux.conf

 

Any pointers would help.

 

TIA

~Anthony

 


DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Pvt. Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Pvt. Ltd. does not accept any liability for virus infected mails.
""" common.py
A common set of functions used across production and sandbox

"""

import os, time
import ConfigParser

class conf:
    
    def __init__(self):
        self.dir = dict()  
        self.vars = []
        self.astConfig = self.getAST()
        #self.vars = 
['rootDir','codeDir','dataDir','searchDir','snippetsDir','snippetStemsDir']
        self.readConf()

    def getAST(self):
        #astConfig = os.path.expandvars('$ASTCONF')
        astConfig = ''
        if astConfig == '': 
                astConfig = "/home/ast/ast-linux.conf"
                os.environ['ASTCONF'] = astConfig
        return astConfig
    
    def readConf(self):
        self.conf = ConfigParser.ConfigParser()
        #self.astConfig = os.path.expandvars('$ASTCONF')
        #astConfig = os.path.expandvars('$ASTCONF')
        #self.astconfig = '/home/ast/ast-linux.conf1'
        a = self.conf.read(self.astConfig)
        #print '<br>self.conf.read=',a

    def readPath(self,target):
        target = target.strip('')
        target = target.strip('\r')
        #print '<br>CONFIG=',self.astConfig
        #print '<br>SECTIONS=',self.conf.sections()
        self.vars = self.conf.options(target)
        #print '\n+++vars=',self.vars        
        if self.conf.has_section(target):
            for var in self.vars:
                self.dir[var] = self.conf.get(target,var)
        #print '+++dir=',self.dir
        return self.dir

    def _test(self):
        import doctest
        doctest.testmod()

        def getTargets(self):
                pass
                #self.conf._sections()
    
if __name__ == "__main__":
    time.clock()
    c = conf()
    dir = c.readPath('production')
    print c.dir

    print 'Elapsed time(s): ', time.clock()
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to