Logo Search packages:      
Sourcecode: zope-externaleditor version File versions  Download package

def ExternalEditor::zopeedit::ExternalEditor::putChanges (   self )
Save changes to the file back to Zope

Definition at line 400 of file zopeedit.py.

        """Save changes to the file back to Zope"""
        if int(self.options.get('use_locks', 0)) and self.lock_token is None:
            # We failed to get a lock initially, so try again before saving
            if not self.lock():
                # Confirm save without lock
                if not askYesNo('Could not acquire lock. '
                                'Attempt to save to Zope anyway?'):
                    return 0
        f = open(self.content_file, 'rb')
        body = f.read()
        headers = {'Content-Type': 
                   self.metadata.get('content_type', 'text/plain')}
        if self.lock_token is not None:
            headers['If'] = '<%s> (<%s>)' % (self.path, self.lock_token)
        response = self.zopeRequest('PUT', headers, body)
        del body # Don't keep the body around longer then we need to

        if response.status / 100 != 2:
            # Something went wrong
            if self.askRetryAfterError(response, 
                                       'Could not save to Zope.\n'
                                       'Error occurred during HTTP put'):
                return self.putChanges()
                return 0
        return 1

Generated by  Doxygen 1.6.0   Back to index