[Htmltmpl] Permission denied if precompiling templates is enabled
Brought to you by:
jakubvrana,
tripiecz
|
From: Andreas M. <a.m...@pe...> - 2002-04-16 20:43:42
|
Hello !
I just tried to use the htmltmpl package for Python. I wrote a small
test cgi:
--------------------------------------
#!C:\Programme\Python\Python.exe
import cgi
import cgitb; cgitb.enable()
from htmltmpl import TemplateManager, TemplateProcessor
# Compile or load already precompiled template.
template = TemplateManager().prepare("template.htm")
tproc = TemplateProcessor()
# Set the title.
tproc.set("title", "Login")
print "Content-Type: text/html\n\n"
print tproc.process(template)
--------------------------------------
But I only get this error message in my browser:
IOError Python 2.2: C:\Programme\Python\Python.exe
Tue Apr 16 22:35:03 2002
A problem occurred in a Python script. Here is the sequence of function
calls leading up to the error, in the order they occurred.
C:\apache\cgi-bin\test.py
8
9 # Compile or load already precompiled template.
10 template = TemplateManager(precompile=1).prepare("template.htm")
11 tproc = TemplateProcessor()
12
template = <function template at 0x00A38058>, TemplateManager = <class
htmltmpl.TemplateManager at 0x00A46FD8>, precompile undefined
C:\Programme\Python\lib\site-packages\htmltmpl.py in
prepare(self=<htmltmpl.TemplateManager instance at 0x00A4D160>,
file='template.htm')
202 if self.is_precompiled(file):
203 try:
204 precompiled = self.load_precompiled(file)
205 except PrecompiledError, template:
206 print >> sys.stderr, "Htmltmpl: bad
precompiled "\
precompiled undefined, self = <htmltmpl.TemplateManager instance at
0x00A4D160>, self.load_precompiled = <bound method
TemplateManager.load_precompiled of <htmltmpl.TemplateManager instance
at 0x00A4D160>>, file = 'template.htm'
C:\Programme\Python\lib\site-packages\htmltmpl.py in
load_precompiled(self=<htmltmpl.TemplateManager instance at 0x00A4D160>,
file=<open file 'template.htmc', mode 'rb' at 0x00A5A238>)
339 finally:
340 if file:
341 self.lock_file(file, LOCK_UN)
342 file.close()
343 if remove_bad and os.path.isfile(filename):
self = <htmltmpl.TemplateManager instance at 0x00A4D160>, self.lock_file
= <bound method TemplateManager.lock_file of <htmltmpl.TemplateManager
instance at 0x00A4D160>>, file = <open file 'template.htmc', mode 'rb'
at 0x00A5A238>, global LOCK_UN = 3
C:\Programme\Python\lib\site-packages\htmltmpl.py in
lock_file(self=<htmltmpl.TemplateManager instance at 0x00A4D160>,
file=<open file 'template.htmc', mode 'rb' at 0x00A5A238>, lock=3)
282 msvcrt.locking(fd, msvcrt.LK_LOCK, 1)
283 elif lock == LOCK_UN:
284 msvcrt.locking(fd, msvcrt.LK_UNLCK, 1)
285 else:
286 raise TemplateError, "BUG: bad lock in lock_file"
global msvcrt = <module 'msvcrt' (built-in)>, msvcrt.locking = <built-in
function locking>, fd = 3, msvcrt.LK_UNLCK = 0
IOError: [Errno 13] Permission denied
__doc__ = 'I/O operation failed.'
__getitem__ = <bound method IOError.__getitem__ of
<exceptions.IOError instance at 0x00A4A5E0>>
__init__ = <bound method IOError.__init__ of <exceptions.IOError
instance at 0x00A4A5E0>>
__module__ = 'exceptions'
__str__ = <bound method IOError.__str__ of <exceptions.IOError
instance at 0x00A4A5E0>>
args = (13, 'Permission denied')
errno = 13
filename = None
strerror = 'Permission denied'
--------------------------------------
When I run the skript in a shell then I receive the correct html text.
I use Apache under Windows XP, my httpd.conf looks like this:
ScriptAlias /cgi-bin/ "/apache/cgi-bin/"
#
# "c:/apache/cgi-bin" should be changed to whatever your
ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/apache/cgi-bin/">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
If I disable the precompiling (template =
TemplateManager(precompile=0).prepare("template.htm") ) then I have no
problems.
Sorry if this is a ridiculous question but I'm not very familiar with
configuring apache and writing cgi scripts.
Thank you
Andreas Martin
|