Issue #1 new

show all / delete

zepolen
created an issue

couple of actions to make it a bit easier to use?

    def all(self, req):
        dir_name = self.profile_path
        link = '<a href="/_profiler/show/%(pid)s">%(pid)s</a>'
        profiles = []
        for profile_file in os.listdir(dir_name):
            if profile_file.endswith('.pkl'):
                modified = os.stat(
                    os.path.join(self.profile_path, profile_file)
                    ).st_mtime
                profiles.append((modified, profile_file))
        profiles.sort(reverse=True)
        res = Response()
        if profiles:
            delete_link = ['<a href="/_profiler/delete">delete all profiles</a>']
            res.body = '<br>'.join(delete_link + [link % {'pid': name[:-4]} for (m, name) in profiles])
        else:
            res.body = 'no profiles'
        return res
    all.exposed = True

    def delete(self, req):
        for filename in os.listdir(self.profile_path):
            if filename.endswith('.pkl') or filename.endswith('.gz'):
                os.unlink(os.path.join(self.profile_path, filename))
        res = Response()
        res.location = '/_profiler/all'
        res.status_int = 302
        return res