|
ron banks
rebcoair at cfl.rr.com
Wed Jul 11 12:07:20 EDT 2007
Jim,
Yes, that was an oversight actually. Removing it doesn't change the
Traceback however.
------------------------Month.tmpl-------------------------
<%
from mod_python import apache, psp
from loadCalendar import loadPan, loadMonth
%>
<%=loadPan()%>
<%=loadMonth(req, =strDate)%>
^^^^^^^
This is how this is supposed to work though right? The value
Month.tmpl.strDate gets set by loadCalendar.setStrDate.strDate?
On Wed, 2007-07-11 at 11:36 -0400, Jim Gallacher wrote:
> Hi Ron,
>
> I'll have some additional comments later, but I just noticed that you
> have a name collision in your month.tmpl. Whatever loadCalendar.strDate
> is will override the value of strDate you set in the line tmpl.run(vars
> = {'strDate': strDate})
>
>
> ----------------loadCalendar/setStrDate----------------
> def setStrDate(req):
> if not hasattr(req, 'session'):
> session = initSession(req)
> strDate = ""
> else:
> session = Session.Session(req)
> strDate = getSessionVariable(session, 'currDate')
> req.content_type = 'text/html'
> tmpl = psp.PSP(req, filename='Month.tmpl')
> tmpl.run(vars = {'strDate': strDate})
> ^^^^^^^
> return ""
>
>
>
> ------------------------Month.tmpl-------------------------
> <%
> from mod_python import apache, psp
> from loadCalendar import loadMonth, strDate
> ^^^^^^^^^^^
> What's this?
>
> %>
>
> <%=loadPan()%>
> <%=loadMonth(req, =strDate)%>
>
>
> Jim
>
> ron banks wrote:
> > 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.
> >
> > _______________________________________________
> > Mod_python mailing list
> > Mod_python at modpython.org
> > http://mailman.modpython.org/mailman/listinfo/mod_python
> >
|