Logo Search packages:      
Sourcecode: zope-emarket version File versions

validateHTTP.py

import urllib
import urlparse
import string
import traceback
import StringIO

def validateHTTP(self, validationURL, validationString, transID, secret, other='', debug=0):
    """
    send a validation response to the original server....
    """
    
    validated = 0
    debugFile = StringIO.StringIO()
    s = ''
    
    try:
        f = urllib.urlopen(validationURL + '?valTransID=' + transID + '&secret=' + secret + other)
        s = f.read()
        f.close()

        if string.find(s, validationString) != -1:
            validated = 1

    except:
        if debug:
            traceback.print_exc(file=debugFile)
            debugFile.seek(0)
            s = s + '\n------ exception during fetch.... -----\n' + debugFile.read()

    return validated, s
        
        
if __name__=='__main__':

    #
    # testing 
    #

    x = validateHTTP(None, 'http://artifactsindy.spvi.com/zope/artifacts/shoppers/joe/validateTransaction',
                     'validated', 'joe-1-927817990.217', 'goobish', other='', debug=1)
    print x
    
   



Generated by  Doxygen 1.6.0   Back to index