[mod_python] Using Templates

ron banks rebcoair at cfl.rr.com
Wed Jul 11 09:50:21 EDT 2007


Jim,

Thanks for the quick reply. I must yield to pretty much anyone on how it
should be done due to previously mentioned newbie status but I have
tried putting the code all in one block and I don't think that is right.
It doesn't error but it just hangs. I'm probably missing the concept
here but the <%=statement%> is like php and is just a placeholder. I get
that. All I want to do is get the variable strDate to the loadMonth
function with the new date string (e.g., "2007,7,11"). What method would
be best for doing that? Here is the complete traceback from the original
code:

Mod_python error: "PythonHandler mod_python.psp"

------------------Traceback------------------
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/psp.py", line 302, in handler
    p.run()

  File "/usr/lib/python2.4/site-packages/mod_python/psp.py", line 213, in run
    exec code in global_scope

  File "/var/www/html/TaskMaster/Month.psp", line 4, in ?
    %>

  File "/var/www/html/loadCalendar.py", line 56, in setStrDate
    tmpl = psp.PSP(req, filename='Month.tmpl')

  File "/usr/lib/python2.4/site-packages/mod_python/psp.py", line 111, in __init__
    self.load_from_file()

  File "/usr/lib/python2.4/site-packages/mod_python/psp.py", line 179, in load_from_file
    code = compile(source, filename, "exec")

  File "/var/www/html/TaskMaster/Month.tmpl", line 22

    req.write("""


""",0); req.write(str(loadPan()),0); req.write("""
""",0); req.write(str(loadMonth(req, =strDate)),0); req.write("""
------------------end------------------

It might be that I can't or shouldn't use templates for what I am trying to accomplish.
Prior to testing templates I pretty much had figured out everything else and probably
just need advise on doing it another way. I have the session being updated with the user
selected date through ajax. What I need is a method to download the same page again with
the loadMonth function using the new date. I was hoping to use a template where I could
set the strDate variable and load the page. Obviously, I'm doing that wrong.



More information about the Mod_python mailing list