Beispiel #1
0
 def _build_uuids(self):
     uuids = {}
     keys = connection.smembers('/project')
     if keys:
         items = [Project.get(uuid)._details for uuid in keys]
         for p in items:
             contract = p.get('contract', '').strip()
             description = p.get('description', '').strip()
             if contract != '':
                 uuids['contract:%s' % (contract)] = p['_uuid']
             if description != '':
                 uuids['description:%s' % (description)] = p['_uuid']
     return uuids
Beispiel #2
0
    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)
Beispiel #3
0
 def revisions(self):
     revisions = connection.smembers('/project/%s' % (self._uuid))
     return revisions
Beispiel #4
0
 def list(cls):
     items = connection.smembers('/project')
     return items