#NEWLINE# def update( self , metadata_entry = None , payload = None , filename = None , mimetype = None , packaging = None , md5sum = None , dr = None , edit_iri = None , edit_media_iri = None , metadata_relevant = False , in_progress = False , on_behalf_of = None ) : #NEWLINE# #INDENT# '\nReplacing the Metadata and/or Files of a Resource\n\n#BETASWORD2URL\nSee http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/trunk/SWORDProfile.html?revision=HEAD#protocoloperations_editingcontent_multipart\n\nReplace the metadata and/or files of a resource.\n\nThis wraps a number of methods and relies on being passed the Deposit Receipt, as the target IRI changes depending \non whether the metadata, the files or both are to be updated by the request. \n\nThis method has the same functionality as the following methods:\n    update_files_for_resource\n    update_metadata_for_resource\n    update_metadata_and_files_for_resource\n\nUsage:\n------\n\nSet the target for this request:\n--------------------------------\n\nYou MUST pass back the `sword2.Deposit_Receipt` object you got from a previous transaction as the `dr` parameter, \nand the correct IRI will automatically be chosen based on what combination of files you want to upload.\n\nThen, add in the metadata and/or file information as desired:\n-------------------------------------------------------------\n\nFile information requires:\n\n    `payload`   - the payload to send. Can be either a bytestring or a File-like object that supports `payload.read()`\n    `mimetype`  - MIMEType of the payload\n    `filename`  - filename. Most SWORD2 uploads have this as being mandatory.\n    `packaging` - the SWORD2 packaging type of the payload. \n                    eg packaging = \'http://purl.org/net/sword/package/Binary\'\n                    \n    `metadata_relevant` - This should be set to `True` if the server should consider the file a potential source of metadata extraction, \n                          or `False` if the server should not attempt to extract any metadata from the deposi\n    \nMetadata information requires:\n\n    `metadata_entry`  - An instance of `sword2.Entry`, set with the metadata required.\n    \nfor example, to create a metadata entry\n    >>> from sword2 import Entry\n    >>> entry = Entry(title = "My new deposit",\n    ...               id = "new:id",    # atom:id\n    ...               dcterms_abstract = "My Thesis",\n    ...               dcterms_author = "Ben",\n    ...               dcterms_issued = "2010")\n\nResponse:\n    \nA `sword2.Deposit_Receipt` object containing the deposit receipt data. If the response was blank or \nnot a Deposit Response, then only a few attributes will be populated:\n            \n    `code` -- HTTP code of the response\n    `response_headers`  -- `dict` of the reponse headers\n    `content`  --  (Optional) in case the response body is not empty but the response is not a Deposit Receipt\n        \nIf exception-throwing is turned off (`error_response_raises_exceptions = False` or `self.raise_except = False`)\nthen the response will be a `sword2.Error_Document`, but will still have the aforementioned attributes set, (code,\nresponse_headers, etc)\n        ' #NEWLINE# target_iri = None #NEWLINE# request_type = 'Update PUT' #NEWLINE# if ( metadata_entry != None ) : #NEWLINE# #INDENT# metadata_relevant = True #NEWLINE# conn_l . info ( 'Using the Edit-IRI - Metadata or Metadata + file multipart-related uses a PUT request to the Edit-IRI' ) #NEWLINE# if ( ( payload != None ) and ( filename != None ) ) : #NEWLINE# #INDENT# request_type = 'Update Multipart PUT' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# request_type = 'Update Metadata PUT' #NEWLINE# #UNINDENT# if ( ( dr != None ) and ( dr . edit != None ) ) : #NEWLINE# #INDENT# conn_l . info ( ( 'Using the deposit receipt to get the Edit-IRI: %s' % dr . edit ) ) #NEWLINE# target_iri = dr . edit #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( edit_iri != None ) : #NEWLINE# #INDENT# conn_l . info ( ( 'Using the %s receipt as the Edit-IRI' % edit_iri ) ) #NEWLINE# target_iri = edit_iri #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# conn_l . error ( 'Metadata or Metadata + file multipart-related update: Cannot find the Edit-IRI from the parameters supplied.' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( payload != None ) and ( filename != None ) ) : #NEWLINE# #INDENT# conn_l . info ( 'Using the Edit-Media-IRI - File update uses a PUT request to the Edit-Media-IRI' ) #NEWLINE# request_type = 'Update File PUT' #NEWLINE# if ( ( dr != None ) and ( dr . edit_media != None ) ) : #NEWLINE# #INDENT# conn_l . info ( ( 'Using the deposit receipt to get the Edit-Media-IRI: %s' % dr . edit_media ) ) #NEWLINE# target_iri = dr . edit_media #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( edit_media_iri != None ) : #NEWLINE# #INDENT# conn_l . info ( ( 'Using the %s receipt as the Edit-Media-IRI' % edit_media_iri ) ) #NEWLINE# target_iri = edit_media_iri #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# conn_l . error ( 'File update: Cannot find the Edit-Media-IRI from the parameters supplied.' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( target_iri == None ) : #NEWLINE# #INDENT# raise Exception ( 'No suitable IRI was found for the request needed.' ) #NEWLINE# #UNINDENT# return self . _make_request ( target_iri = target_iri , metadata_entry = metadata_entry , payload = payload , mimetype = mimetype , filename = filename , packaging = packaging , on_behalf_of = on_behalf_of , in_progress = in_progress , metadata_relevant = str ( metadata_relevant ) , method = 'PUT' , request_type = request_type , md5sum = md5sum )