Skip to content

Instantly share code, notes, and snippets.

@saverkamp

saverkamp/catcher.py

Last active May 1, 2018
Embed
What would you like to do?
Python class to overlay metadata in CONTENTdm via Catcher (edit only). Catcher docs at: http://contentdm.org/help6/addons/catcher.asp Sample script using this class at: https://gist.github.com/saverkamp/9198310
from suds.client import Client
class Catcher(object):
"""A CONTENTdm Catcher session."""
def __init__(self, url=url, user=user, password=password, license=license):
self.transactions = []
self.client = Client('https://worldcat.org/webservices/contentdm/catcher/6.0/CatcherService.wsdl')
self.url = url
self.user = user
self.password = password
self.license = license
def processCONTENTdm(self, action, user, password, license, alias, metadata):
# function to connect to CatcherServices and process metadata updates
transaction = self.client.service.processCONTENTdm(action, url, user, password, license, alias, metadata)
self.transactions.append(transaction)
def edit(self, alias, recordid, field, value):
#function to edit metadata--call packageMetadata and processCONTENTdm
metadata = self.packageMetadata('edit', recordid, field, value)
self.processCONTENTdm('edit', self.user, self.password, self.license, alias, metadata)
def packageMetadata(self, action, recordid, field, value):
#function to package metadata in metadata wrapper
action = action
if action == 'edit':
metadata = self.client.factory.create('metadataWrapper')
metadata.metadataList = self.client.factory.create('metadataWrapper.metadataList')
metadata1 = self.client.factory.create('metadata')
metadata1.field = 'dmrecord'
metadata1.value = recordid
metadata2 = self.client.factory.create('metadata')
metadata2.field = field
metadata2.value = value
metadata.metadataList.metadata = [metadata1, metadata2]
return metadata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.