def remove(self, filename): if self._is_logged_in(): if self.validate_path(filename): user_dir = self.get_user_dir() silentremove('%s/%s' % (user_dir, filename)) return get_response(200, 'File %s deleted' % filename) else: return get_response(403, 'No access to file %s' % filename) else: return get_response(403, 'Not logged in')
def get_cookie(cls, cookie): """ Load a saved cookie from file. """ cookie_name = '%s/%s.cookie' % (cls.SESSION_PATH, cookie) if os.path.exists(cookie_name): if time.time() - os.stat(cookie_name).st_mtime > cls.TIMEOUT: silentremove(cookie_name) return None else: # Update the access time os.utime(cookie_name, None) return open(cookie_name, 'r').readline() else: return None
def destroy_cookie(cls, cookie): """ Delete cookie file. """ cookie_name = '%s/%s.cookie' % (cls.SESSION_PATH, cookie) silentremove(cookie_name)