[mod_python] Re: modifying psp_site

Reed L. O'Brien reedobrien at acm.org
Mon Jun 21 15:34:43 EDT 2004


####I am now here. The formcalls results

<form action="results" method="POST">

####results is as follows

def results(req, searchWords):
      if not (searchWords):
          #req.write
          answer = "<H2>Nothing to search for. Nothing Found</H2>"
 

      handle = SwishE.new('/usr/local/swish-e/index.swish-e')
      search = handle.search('')
      results = search.execute(searchWords)
      files = [r.getproperty('swishdocpath') for r in results]
 

      #req.write
      answer = "The files found are: %s" % files

      return _any_page(req, 'results')

#####So when the results_template.html

<p>
<h3>Search Results</h3>

<p>
  <%answer%>

#####it inserts

Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

   File "/usr/local/lib/python2.3/site-packages/mod_python/apache.py", 
line 299, in HandlerDispatch
     result = object(req)

   File 
"/usr/local/lib/python2.3/site-packages/mod_python/publisher.py", line 
143, in handler
     result = str(result)

   File "/usr/local/lib/python2.3/site-packages/mod_python/psp.py", line 
228, in __str__
     self.run()

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

   File "/usr/local/www/data/python/templates/main_frame.html", line 12, 
in ?
     %>

   File "/usr/local/lib/python2.3/site-packages/mod_python/psp.py", line 
228, in __str__
     self.run()

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

   File "/usr/local/www/data/python/templates/results_body.html", line 
1, in ?

NameError: name 'answer' is not defined

I don't know why it is not defined.  If I call req.write direct in 
results() it will spit out answer and the the html from the template as 
plain text tags included.

I have tried calling the function in psp tags to no avail.  searchWords 
is then undefined.  I guess what I need to know is how to pass those 
variable to the html templates.  DO I need to import something, within 
psp tags, in the html template?

TIA



Reed L. O'Brien wrote:

>
> 
> PSS:
> FreeBSD 5.2.1
> mod_python 3.1.3
> python 2.3.4
> SwishE 0.4


-- 


reed
4.6692016090



More information about the Mod_python mailing list