def edit(cls, uuid): data = connection.get('/project/%s/edit' % (uuid)) if not data: details = Project.get(uuid, as_json=True) data = dump_to_json(details) connection.set('/project/%s/edit' % (uuid), data) else: details = json.loads(data) project = cls(details) project.edit = True return project
def get(cls, uuid, as_json=False): revisions = connection.smembers('/project/%s' % (uuid)) if not revisions: raise DoesNotExistException('There is no data for project %s.' % (uuid)) revision_map = [{ 'timestamp': UUID(r.split('/')[-1]).timestamp(), 'key': '/project/%s/%s' % (uuid, r) } for r in revisions] revision_map.sort(key=lambda x: x['timestamp'], reverse=True) data = connection.get(revision_map[0]['key']) details = json.loads(data) if as_json: return details return cls(details)