def delattach( self, attach, hthdrs={}, **query ) : """Delete the attachment specified either as filename or Attachment object, from this design-document. >>> doc.delattach( 'default.css' ) >>> attach = doc.attach( 'default.css' ) >>> doc.delattach( attach ) """ filename = attach.filename \ if isinstance(attach, Attachment) else attach hthdrs = self.conn.mixinhdrs( self.hthdrs, hthdrs ) d = Attachment.delattachment( self.db, self, filename, hthdrs=hthdrs, **query ) self.doc.update({ '_rev' : d['rev'] }) if d and 'rev' in d else None return None
def addattach( self, filepath, content_type=None, hthdrs={}, **query ) : """Add file specified by ``filepath`` as attachment to this design-document. HTTP headers 'Content-Type' and 'Content-Length' will also be remembered in the database. Optionally, ``content_type`` can be provided as key-word argument. Return :class:`couchpy.attachment.Attachment` object. Admin-prev, No """ data = open( filepath ).read() filename = basename( filepath ) hthdrs = self.conn.mixinhdrs( self.hthdrs, hthdrs ) d = Attachment.putattachment( self.db, self, filepath, data, content_type=content_type, hthdrs=hthdrs, **query ) self.doc.update({ '_rev' : d['rev'] }) if d and 'rev' in d else None return Attachment( self, filename )