def __init__(self, baseUrl=default_baseUrl):
     client = ServiceClient(baseUrl)
     params = {'verb': 'ListCollections'}
     request = client.setRequest(params)
     response = client.getResponse()
     if response.hasError():
         raise Exception, response.error
     self.results = self.parseResponse(response)
Exemple #2
0
 def __init__(self, baseUrl, recId, item_record_class=XmlRecord):
     client = ServiceClient(baseUrl)
     params = {'verb': 'GetRecord', 'id': recId}
     request = client.setRequest(params)
     response = client.getResponse()
     if response.hasError():
         raise Exception, response.error
     self.result = self.parseResponse(response, item_record_class)
Exemple #3
0
	def __init__ (self, catServer):
		self.server = CATGlobals.servers[catServer]
		if not self.server:
			raise KeyError, "cat server not found for '%s'" % catServer
		self.credentials = {
			'username': self.server['username'],
			'password': self.server['password']
		}
		# params_obj['username'] = server
		# params_obj['password'] = server['password']
		ServiceClient.__init__ (self, self.server['baseUrl'])
Exemple #4
0
 def __init__(self, recId):
     client = ServiceClient(self.baseUrl)
     params = {
         'verb': 'GetRecord',
         'id': recId,
         'storedContent': ['dcsstatus', 'dcsstatusNote']
     }
     request = client.setRequest(params)
     response = client.getResponse()
     if response.hasError():
         raise Exception, response.error
     self.result = self.parseResponse(response)
Exemple #5
0
    def __init__(self, collection=None, xmlFormat=None, baseUrl=None):
        UserList.__init__(self)
        baseUrl = baseUrl or self.default_baseUrl
        if self.verbose:
            print 'baseUrl:', baseUrl
        self.timing = {}
        self.params = self.get_params(collection, xmlFormat)
        self.service_client = ServiceClient(baseUrl)
        self.numRecords = self._get_num_records()
        if self.verbose:
            print "%d total records" % self.numRecords
        s = 0
        numToGet = min(self.numToFetch, self.numRecords)

        tics = time.time()
        self.getResults(numToGet)
        self.timing['download'] = time.time() - tics

        self.numFetched = len(self)

        tics = time.time()
        self.filterResults()
        self.timing['filter'] = time.time() - tics

        tics = time.time()
        self.processResults()
        self.timing['processing'] = time.time() - tics
Exemple #6
0
	def __init__ (self, collectionKey, baseUrl=default_baseUrl):
		client = ServiceClient (baseUrl)
		params = {
			'n' : '1',
			's' : '0',
			'verb':'Search',
			'ky': collectionKey,
			"storedContent":['dcsndrHandle']
		}
		request = client.setRequest (params)
		self.result = None
		# print request.report()
		try:
			response = client.getResponse()
		except:
			raise Exception, "couldn't parse result for collectionKey='%s'\nRoot cause: %s" % (collectionKey, sys.exc_info()[1])
		if response.hasError():
			raise Exception, response.error
		self.result = self.parseResponse(response)
Exemple #7
0
def formatSearch ():
	# we're getting collection records - use NCSCollectRecord
	baseUrl = NLDR_DDS_URL
	params = {
	"verb": "Search",
	"xmlFormat": "library_dc",
	}

	client = ServiceClient (baseUrl)
	item_constructor = XmlRecord
	getter = RecordGetter(client, params, item_constructor)
	print getter.recs[3]
Exemple #8
0
    def __init__(self, term, searchFields):
        UserList.__init__(self)
        self.term = term
        if type(searchFields) == type(""):
            self.searchFields = [searchFields]
        else:
            self.searchFields = searchFields

        self.params = self.get_params(None, None)
        self.service_client = ServiceClient(self.baseUrl)
        self.numRecords = self._get_num_records()
        if self.verbose:
            print "%d total records" % self.numRecords
Exemple #9
0
	def getResponse (self, preprocessor=None):
		"""
		simply return response from server as an XmlRecord instance
		"""
		response = ServiceClient.getResponse (self, preprocessor)
		if not response.hasError():
			# now test for CAT error
				error = response.doc.selectSingleNode (response.doc.dom, 'CATWebService:Error')
				if error:
					statusMessage = XmlUtils.getChildText (error, "StatusMessage")
					returnCode = XmlUtils.getChildText (error, "ReturnCode")
					response.error = CatResponseError ([statusMessage, returnCode])
			
			
			#self.result = response.doc
		return response
Exemple #10
0
 def __init__(self, baseUrl=default_baseUrl):
     self.params = {'verb': 'ListCollections'}
     self.service_client = ServiceClient(baseUrl)
     self.data = self.getResults()
Exemple #11
0
	}

	client = ServiceClient (baseUrl)
	item_constructor = XmlRecord
	getter = RecordGetter(client, params, item_constructor)
	print getter.recs[3]

if __name__ == '__main__':

	baseUrl = UCONN_DCS_URL
	CMC = '1201216476279' # key for Ucar Collection Management Collection

	# query for specific view Context
	q='/key//record/collection/viewContexts/viewContext:"DLESECollections"'
	params = {
		"verb" : "Search",
		"ky" : CMC,
		"q" : q
	}

	client = ServiceClient (baseUrl)
	item_constructor = NCSCollectRecord
	getter = RecordGetter(client, params, item_constructor)
	print "%d records returned" % len(getter.recs)
	# sort the recs by title
	getLabel = lambda x:x.getTitle()
	getter.recs.sort(key=getLabel)
	for rec in getter.recs:
		print '-', getLabel(rec)

 def __init__(self, pubs_id, collections=None, baseUrl=default_baseUrl):
     UserList.__init__(self)
     self.pubs_id = pubs_id
     self.params = self.get_params()
     self.service_client = ServiceClient(baseUrl)
     self.data = self.getResults()
Exemple #13
0
 def __init__(self, recId, baseUrl=default_baseUrl):
     self.recId = recId
     self.params = self.get_params()
     self.service_client = ServiceClient(baseUrl)
     self.response = self.getResult()