def render_PUT(self, request): result = WebdavResource.render_PUT(self, request) if result is not None and result.has_key(request.path) and \ request.env['CONTENT_TYPE'].strip().find('text/calendar') == 0: user=request.env.get('user') stream = self.storageProvider.get(request.path, user=user) try: event = vobject.readOne(stream) self.calendarProvider.store(request.path, event, user=user) # generate the etag data and add it to the document. stream.seek(0) md5Sum = getMD5(stream) md5Sum.update(request.path) etag = md5Sum.hexdigest() request.setHeader("ETag", "%s" % etag) self.storageProvider.setMeta(request.path, {'{DAV:}getetag': "%s" % etag, '{DAV:}getcontenttype': 'text/calendar' }, user=user ) except Exception as ex: logging.getLogger().warn('Not a calendar object. Got error: %s' % ex) finally: stream.close() return result
def render_PUT(self, request): result = WebdavResource.render_PUT(self, request) if result is not None and result.has_key(request.path): user = request.env.get('user') stream = self.storageProvider.get(request.path, user=user) md5Sum = getMD5(stream) md5Sum.update(request.path) etag = md5Sum.hexdigest() request.setHeader("ETag", "%s" % etag) self.storageProvider.setMeta(request.path, {'{DAV:}getetag': "%s" % etag}, user=user ) stream.seek(0) event = vobject.readOne(stream) self.contactProvider.store(request.path, event) return result