Changeset 5445 for ndgCommon


Ignore:
Timestamp:
01/07/09 16:06:34 (10 years ago)
Author:
cbyrom
Message:

Extend generichttpclient to allow http method to be set on request +
update vocabserverclient to do a PUT request following a POST one
should an update already have been ran on a particular term - to allow
this update to be overwritten.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/src/clients/http/generichttpclient.py

    r5443 r5445  
    88from ndg.common.src.lib.utilities import httpify 
    99             
     10VALID_HTTP_METHODS = ['POST', 'PUT', 'GET', 'DELETE']             
    1011class GenericHTTPClient(object): 
    1112    '''  
     
    3031 
    3132         
    32     def readURL(self, url, payload = None, headersDict = None): 
     33    def readURL(self, url, payload = None, headersDict = None, httpMethod = 'GET'): 
    3334        ''' 
    3435        Retrieve contents of url - or raise IOError if a problem is found 
     
    3637        @keyword payload: data to POST in the request  
    3738        @keyword headersDict: dict with headers info to use in the request  
     39        @keyword httpMethod: method to use with http - either GET, PUT, POST or DELETE.   
     40        Default = 'GET'  
    3841        @raise IOError if problem experienced whilst opening url 
    3942        @return contents of url  
     
    4952             
    5053        request=urllib2.Request(url, **inputs) 
     54         
     55        if httpMethod not in VALID_HTTP_METHODS: 
     56            raise ValueError("Unrecognised http method, '%s'" %httpMethod) 
     57             
     58        request.get_method = lambda: httpMethod 
     59         
    5160        response='Cannot obtain remote file: ' 
    5261        try: 
Note: See TracChangeset for help on using the changeset viewer.