Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Jan 15th, 2007, 1:10 PM   #1
somehollis
Programmer
 
somehollis's Avatar
 
Join Date: May 2006
Location: Memphis, TN
Posts: 31
Rep Power: 0 somehollis is on a distinguished road
Send a message via AIM to somehollis
Cannot open a file with mod_python

My apologies if this should have gone in the web programming forum. Since it pertains to python, I was uncertain.

I'm trying to finish up a small web app that I've been working on (written in python). The gist of it is that it allows me (and my fellow students) to easily track our billing for patients that we have seen. The back end is finished and functional, and I've been working on integrating the web GUI.

The problem arises, however, when I move all my files over to my apache directory (/var/www). Once my files are there, the program can't seem to find them. I've tried using the full path (/var/www/data/cptcodes2007), the path relative to the webserver (/data/cptcodes2007), and simply having the files in the same dir as my .py files.

The file can be read by browsing (in firefox) to localhost/data/cptcodes, and some independent scripts I wrote to check for mod_python functionality work correctly, so I don't believe that it is an apache configuration issue (though I will readily admit I know very little about apache as of yet).

Am I simply trying to look for the file in the wrong place? Am I using os.path.isfile(filename) incorrectly? Relevant code from my test script and the actual routine to read the file posted below. The red section is the error that is being raised.
Test script:
from mod_python import apache, util, psp
import audiclock
import sha
import os

def index(req):
	# The publisher will call this function as default,
	req.write('running _get_vars()<br />')
	_get_vars(req)
	
def _get_vars(req):
	formData = req.form
	req.write('grabbed form data; here is what I am seeing:<br />')
	for item in formData.keys():
		req.write('%s:\t%s<br />' % (item, formData[item]))
	req.write('running _set_page()<br />')
	_set_page(req, formData)


def _set_page(req, formData):
	audiclock.read_all()
	if formData.has_key('currentPage') and formData['currentPage'] == 'process_me':
		if formData.has_key('luser') and formData.has_key('lapp') and formData.has_key('lpatient'):
			for item in formData.keys():
				if item in audiclock.cptCode.keys() and formData['item'] == "on":
					audiclock.final_result(formData['lapp'], formData['lpatient'], item, formDatap['luser'])
					req.write('Item %s recorded.<br />' % (item))
				else:
					req.write('%s did not match<br />' % (item))
		else:
			req.write('formData was missing either luser, lapp, or lpatient<br />')
	else:
		req.write("didn't find 'currentPage' or value wasn't 'process_me'<br />")
Main program's import function (the first one called by audiclock.read_all() ) The filename being passed to this function is any of what I have tried above (e.g. /var/www/data/cptcodes2007)
def read_cptfile(filename):
	'''This function will import cpt codes into cptBase var.'''
	if not os.path.isfile(filename):
		raise IOError, "No cpt data found.  Please ensure that the  path for file (%s) is correct" % (filename)
	else:
		try:
			try:                        # Open the data file and import it
				inFile = open(filename, "r")
				for line in inFile:
					if line == "": break
					if not re.match(line, '^#') and not re.match(line, '^$'):
						line = line.strip()
						cptCode[line.split(':')[0]],cptDescription[line.split(':')[0]],physicianRVU[line.split(':')[0]],nonFacilityRVU[line.split(':')[0]],malpracticeRVU[line.split(':')[0]],nonFacilityRVU[line.split(':')[0]],cptFee[line.split(':')[0]] = line.split(':')[:]
			except IOError:             # If  file can't be read, we have a problem
				print "File '%s' could not be read.  Check file permissions." % (filename)
				sys.exit()
		finally:
			inFile.close()
somehollis is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OnlineTextEditor.Com! Sane Show Off Your Open Source Projects 43 Jun 16th, 2006 9:55 AM
Command Prompt SkyPioneer Coder's Corner Lounge 5 May 3rd, 2006 11:07 PM
Help using this function Eric the Red Visual Basic 10 Feb 27th, 2006 11:26 AM
After execution - Error cannot locate /Skin File? wchar Visual Basic 1 Mar 5th, 2005 10:04 PM
airport Log program using 3D linked List : problem reading from file gemini_shooter C++ 0 Mar 2nd, 2005 5:12 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:32 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC