-
Notifications
You must be signed in to change notification settings - Fork 26
Quickstart
== Install ==
The package is in the Pypi cheeseshop so can be installed via:
easy_install sword2
== Use ==
The key classes in the module are Connection (the HTTP/SWORD2 client) and Entry (easy means to create metadata (atom) entry documents).
=== Connect to a sword server using the URL for its service document (SD_URI), pick a collection and submit a zip file to the collection: ===
{{{ #!python from sword2 import Connection c = Connection(SD_URI, user_name = "foo", user_pass="bar") c.get_service_document()
workspace_1_title, workspace_1_collections = c.workspaces[0] collection = workspace_1_collections[0]
with open("package.zip", "r") as pkg: receipt = c.create(col_iri = collection.href, payload = pkg, mimetype = "application/zip", filename = "package.zip", packaging = 'http://purl.org/net/sword/package/Binary', in_progress = True) # As the deposit isn't yet finished
from sword2 import Entry
e = Entry(id="atomid", title="atom-title", dcterms_abstract = "Info about the resource....", etc... )
e.register_namespace('skos', 'http://www.w3.org/2004/02/skos/core#') e.add_field("skos_Concept", "...")
updated_receipt = c.update(metadata_entry = e, dr = receipt, # use the receipt to discover the right URI to use in_progress = False) # finish the deposit
}}}