The oaipmh module implements the OAI-PMH protocol. It encapsulates 16 | this protocol in Python, so that a request to the OAI-PMH server is 17 | just a method call from the Python perspective. The XML data that is 18 | returned from the server is processed as well, and returned as Python 19 | objects.
20 |class ServerProxy(uri [, metadataSchemaRegistry])
24 |25 |101 |A ServerProxy instance is an object that manages communication with 26 | the remote OAI-PMH server. The required first argument is the URI 27 | that accepts OAI-PMH requests.
28 |The second optional argument is a MetadataSchemaRegistry 29 | instance. This registry contains the metadata schemas that are 30 | understood by client. If it isn't supplied, a default and global 31 | schema registry will be used, with at least support for the 32 | oai_dc metadata scheme.
33 |The returned instance is a proxy object with methods that can be 34 | used to invoke the corresponding OAI-PMH requests to the server. The 35 | methods are named after the corresponding verbs of the OAI-PMH 36 | protocol, though start with a lowercase letter to follow Python 37 | camelCase conventions.
38 |The methods take zero or more keyword arguments; non-keyword 39 | arguments are not supported. The methods do some automatic checking 40 | to determine whether the right combination of arguments is used.
41 |The section Protocol Requests and Responses of the OAI-PMH 42 | standard describes the verbs (and thus methods) and the allowed 43 | arguments combinations.
44 |getRecord(identifier, metadataPrefix)
45 |46 | Returns a header, metadata, about tuple for the identified item.47 |identify()
48 |49 | Get server identification information. This returns a 50 | ServerIdentify instance.51 |listIdentifiers(metadataPrefix [, from_ [, until [, set [, resumptionToken [, max]]]]])
52 |53 |57 |Returns a lazy sequence of Header instances.
54 |The result can be restricted using from_ and until arguments.
55 |The result can be restricted for one particular set.
56 |listMetadataFormats([identifier])
58 |59 |71 |If identifier is not specified, returns a list of 60 | metadataPrefix, schema, metadataNamespace tuples for this 61 | OAI-PMH repository.
62 |If identifier is specified, returns a list of tuples for the 63 | metadata associated with the identified item.
64 |metadataPrefix is a short string to uniquely identify the 65 | metadata format for this OAI-PMH repository.
66 |schema is a URI to the XML schema describing the metadata 67 | format.
68 |metadataNamespace is a namespace URI used for to identify XML 69 | content in this metadata format.
70 |listRecords(metadataPrefix [, from_ [, until [, set [, resumptionToken [, max]]]]])
72 |73 |78 |Returns a lazy sequence of header, metadata, about tuples 74 | for items in the repository.
75 |The result can be restricted using from_ and until arguments.
76 |The result can be restricted for one particular set.
77 |listSets([resumptionToken [, max]])
79 |80 |90 |Returns a lazy sequence of setSpec, setName, setDescription 81 | tuples.
82 |setSpec is the repository-unique name of a set. It may be 83 | partioned into a hierarchy using a colon. See the section Set 84 | of the OAI-PMH standard for more information.
85 |setName is the name of the set as it should be displayed to 86 | end-users.
87 |At the of writing setDescription is not yet supported by the 88 | oaipmh module, and this element of the tuple will always be None.
89 |The following methods pertain to the metadata schema system.
91 |addMetadataSchema(schema)
92 |93 | Add a MetadataSchema instance to the ServerProxy. The server 94 | will then be able to create Metadata instances for metadata in 95 | the format handled by the MetadataSchema instance.96 |getMetadataSchemaRegistry()
97 |98 | Get the MetadataSchemaRegistry instance that handles metadata 99 | for this ServerProxy instance.100 |
class Header(..)
102 |103 |128 |identifier()
104 |105 |111 |Returns the unique identifier of this item in this repository. The 106 | identifier must be in URI form. Some repositories may for instance 107 | implement this as handles (see www.handle.net).
108 |See the Unique Identifier section of the OAI-PMH standard for 109 | more information.
110 |datestamp()
112 |113 | Returns the time at which this item was added or last updated 114 | within the repository. This is in string form, in UTCdatetime 115 | format.116 |setSpec()
117 |118 |127 |119 | Returns a list of the sets this item is in. The object may be in 120 | zero or more sets. Sets are represented as strings. See also the 121 | section Set of the OAI-PMH standard.122 |isDeleted()
123 |124 | Returns true if this item is deleted from the server, and this is 125 | a delete notification.126 |
class Metadata(..)
129 |130 |141 |getMap()
131 |132 | Returns a dictionary with as key the metadata field names and as 133 | values the metadata values, as extracted from the XML.134 |getField(name)
135 |136 |140 |Returns the metadata value for metadata field name name.
137 |There is also a dictionary API that is the equivalent of getField; 138 | metadata[name].
139 |
class SeverIdentify(..)
142 |143 |191 |repositoryName()
144 |145 | Returns the human readable name of the repository.146 |baseURL()
147 |148 | Returns the base URL for the repository (which can receive OAI-PMH 149 | requests).150 |protocolVersion()
151 |152 | Returns the version of the OAI-PMH protocol supported by the 153 | repository.154 |earliestDatestamp()
155 |156 | Returns a UTCdatetime that is the guaranteed earliest datestamp 157 | that can occur in headers.158 |deletedRecord()
159 |160 |177 |Returns an string indicating how the repository deals with deleted 161 | records.
162 |no
163 |164 | The repository does not support deleted records in the 165 | protocol. If records are deleted they don't appear anymore, but 166 | no special information is returned about them.167 |transient
168 |169 | Deleted records will be returned with isDeleted status in 170 | the header set as true but these will not be returned forever.171 |persistent
172 |173 | Deleted record information is stored permanently by the server 174 | and will be returned with isDeleted status as true if the 175 | deleted item is accessed.176 |granularity()
178 |179 | Returns either YYYY-MM-DD or YYYY-MM-DDThh:mm:ssZ. This determines 180 | the finest granularity of timestamps returned by the server.181 |adminEmails()
182 |183 | Returns a list of one or more email addresses of server admins.184 |compression()
185 |186 | Returns the compression encoding supported by the repository.187 |description()
188 |189 | Not yet implemented.190 |
class MetadataSchema(metadata_prefix, namespaces)
192 |193 |220 |Instances of this class describe ways to turn an XML representation 194 | of metadata into python Metadata instances. Fields are described by 195 | a name, a type and a way to retrieve the field information (in the 196 | form of a string or a list of strings) from the XML representation. 197 | The latter is described by an XPath expression. This way other 198 | metadata schemas can be represented in Python by adding a new 199 | MetadataSchema to the ServerProxy's metadata schema registry.
200 |addFieldDescription(field_name, field_type, xpath)
201 |202 |219 |Add a field description to the metadata schema.
203 |field_name
204 |205 | The name of the field in the Metadata instances generated 206 | according to this schema.207 |field_type
208 |209 | A string indicating the data type of the metadata 210 | field. bytes indicates an 8-bit string, bytesList 211 | indicates a list of such strings, text indicates a unicode 212 | string and textList indicates a list of unicode strings.213 |xpath
214 |215 | And XPath expression that is executed from the top of the 216 | particular metadata section in the retrieved XML. This 217 | expression indicates how to retrieve the metadata.218 |
class MetadataSchemaRegistry()
221 |222 |229 |Instances of this class store a number of MetadataSchema 223 | instances. These handle metadata found in OAI-PMH XML resultsets 224 | according to their metadata_prefix.
225 |addMetadataSchema(metadata_schema)
226 |227 | Add a MetadataSchema instance to this registry.228 |
header is a Header instance.
232 |metadata is a Metadata instance if the metadataPrefix argument 233 | is in a registered format, or None if the metadataPrefix is not 234 | recognized.
235 |At the time of writing about support has not yet been implemented 236 | and will always be returned as None.
237 |The from_ and until arguments are optional and can be used to 241 | restrict the result to information about items which were added or 242 | modified after from_ and before until. from_ is spelled 243 | with the extra _ because from (without underscore) is a 244 | reserved keyword in Python. If only from_ is used there is no 245 | lower limit, it only until is used there is no upper limit. Both 246 | arguments should be strings in OAI-PMH datestamp format 247 | (i.e. YYY-MM-DDDThh:mm:ssZ). See the UTCdatetime section of 248 | the OAI-PMH standard for more information.
249 |The list is lazy in that while you can loop through it, it behaves 253 | more like an iterator than a real list (it would be a real Python 2.2+ 254 | iterator if Python 2.1 did not need to be supported by this 255 | module). The system automatically asks for the next resumptionToken if 256 | one was in the reply. While you can explicitly pass a resumptionToken 257 | this is therefore not very useful as the lazy lists take care of 258 | resumptionTokens automatically.
259 |The optional max argument is not part of the OAI-PMH protocol, but 260 | a coarse way to control how many items are read before stopping. If 261 | the amount of items exceeds max after reading a resumptionToken, 262 | the method will halt.
263 |