[mod_python] Spry Framework and interfacing with mod_python/Vampire

wayne collier Wayne.Collier at noaa.gov
Mon Dec 8 15:33:52 EST 2008

I am trying perform AJAX function call on my website using Spry 
framework. I am a little lost on how to  send  data to my python 
function. I was able to get the following code to work using urlparse 
commandas in server code. However, can get this going using the standard 
mod_python/vampire construct (e.g. ss=req.form['data1_value'] ). I can't 
seem to grab the _postdata_ I am placing in the
**Spry.Utils.loadURL command. **Can someone help me with this?   


  function ajax_request(){
  var data1_value = document.sample.first.value;
  var data2_value = document.sample.last.value;
  var formData = 'first='+data1_value+'&last='+data2_value;
   //The next line is to encode the variables values e.g. weird characters to make it safe for transfer
  formData = encodeURI(formData);
  var  url="http://mingus.ncd-tcn.noaa.gov/dev/python/jsonExample.py/breakthru?"+formData;
  formData = encodeURI(formData);
  *var req=Spry.Utils.loadURL('POST', url, true, ReturnTask,{postdata:formData, headers:{"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}});
  function ReturnTask(req){
   //We use xhRequest to received notification from server side, usually the process file will return with an echo/write.
   var result = req.xhRequest.responseText; 
   document.getElementById("notice").innerHTML =result;



def breakthru(req):
   # req.content_type='text/html'   
    from cgi import escape
    from urllib import unquote
    import vampire
    import mod_python
    from mod_python import util
    from urlparse import urlparse

    d={"first":"Stevenrr","last":"Spielberg","address":"1234 Unlisted 

    for attrib in dir(req):
        attribs += '<tr><td>%s</td><td>%s</td></tr>'
        attribs %= (attrib, 

    req.write(str(test)+  '<br>')
    return "<br> name:" +first

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20081208/5ee33671/attachment.html

More information about the Mod_python mailing list