'Catches the dataset id and displays file contents as directed'

@web.expose
def download_dataset_from_folder(self, trans, cntrller, id, library_id=None, **kwd):

    show_deleted = util.string_as_bool(kwd.get('show_deleted', False))
    use_panels = util.string_as_bool(kwd.get('use_panels', False))
    is_admin = (trans.user_is_admin() and (cntrller == 'library_admin'))
    current_user_roles = trans.get_current_user_roles()
    try:
        ldda = trans.sa_session.query(trans.app.model.LibraryDatasetDatasetAssociation).get(trans.security.decode_id(id))
    except:
        ldda = None
    self._check_access(trans, cntrller, is_admin, ldda, current_user_roles, use_panels, library_id, show_deleted)
    composite_extensions = trans.app.datatypes_registry.get_composite_extensions()
    ext = ldda.extension
    if (ext in composite_extensions):
        kwd['do_action'] = 'zip'
        return self.act_on_multiple_datasets(trans, cntrller, library_id, ldda_ids=[id], **kwd)
    else:
        trans.response.set_content_type(ldda.get_mime())
        fStat = os.stat(ldda.file_name)
        trans.response.headers['Content-Length'] = int(fStat.st_size)
        fname = ldda.name
        fname = ''.join(((((c in FILENAME_VALID_CHARS) and c) or '_') for c in fname))[0:150]
        trans.response.headers['Content-Disposition'] = ('attachment;    filename="%s"' % fname)
        try:
            return open(ldda.file_name)
        except:
            message = 'This    dataset    contains    no    content'
    return trans.response.send_redirect(web.url_for(controller='library_common', action='browse_library', cntrller=cntrller, use_panels=use_panels, id=library_id, show_deleted=show_deleted, message=message, status='error'))
