Package yadis :: Module services
[hide private]
[frames] | no frames]

Source Code for Module yadis.services

 1  from yadis.filters import mkFilter 
 2  from yadis.discover import discover 
 3  from yadis.etxrd import parseXRDS, iterServices 
 4   
5 -def getServiceEndpoints(input_url, flt=None):
6 """Perform the Yadis protocol on the input URL and return an 7 iterable of resulting endpoint objects. 8 9 @param flt: A filter object or something that is convertable to 10 a filter object (using mkFilter) that will be used to generate 11 endpoint objects. This defaults to generating BasicEndpoint 12 objects. 13 14 @param input_url: The URL on which to perform the Yadis protocol 15 16 @return: The normalized identity URL and an iterable of endpoint 17 objects generated by the filter function. 18 19 @rtype: (str, [endpoint]) 20 """ 21 result = discover(input_url) 22 endpoints = applyFilter(result.normalized_uri, result.response_text, flt) 23 return (result.normalized_uri, endpoints)
24
25 -def applyFilter(normalized_uri, xrd_data, flt=None):
26 """Generate an iterable of endpoint objects given this input data, 27 presumably from the result of performing the Yadis protocol. 28 29 @param normalized_uri: The input URL, after following redirects, 30 as in the Yadis protocol. 31 32 33 @param xrd_data: The XML text the XRDS file fetched from the 34 normalized URI. 35 @type xrd_data: str 36 37 """ 38 flt = mkFilter(flt) 39 et = parseXRDS(xrd_data) 40 41 endpoints = [] 42 for service_element in iterServices(et): 43 endpoints.extend( 44 flt.getServiceEndpoints(normalized_uri, service_element)) 45 46 return endpoints
47