Revision 63092950 snf-pithos-backend/pithos/backends/modular.py

b/snf-pithos-backend/pithos/backends/modular.py
388 388
    def list_accounts(self, user, marker=None, limit=10000):
389 389
        """Return a list of accounts the user can access."""
390 390

  
391
        return self._allowed_accounts(user)
392

  
393
    def _get_account_quotas(self, account):
394
        """Get account usage from astakos."""
395

  
396
        quotas = self.astakosclient.service_get_quotas(account)[account]
397
        return quotas.get(DEFAULT_SOURCE, {}).get(DEFAULT_DISKSPACE_RESOURCE,
398
                                                  {})
391
        paths = self._allowed_accounts(user)
392
        d = self.node.node_lookup_bulk(paths)
393
        if not d:
394
            return ()
395
        nodes = d.keys()
396
        props = self.node.version_lookup_bulk(nodes, cluster=CLUSTER_NORMAL)
397
        mtimes = dict((p[self.NODE], p[self.MTIME]) for p in props)
398
        statistics = self.node.statistics_latest_bulk(nodes,
399
                                                      except_cluster=
400
                                                      CLUSTER_DELETED)
401
        meta = []
402
        append = meta.append
403
        for node, count, size, mtime in statistics:
404
            append({'name': d[node], 'modified':  max(mtimes[node], mtime)})
405
        return meta
399 406

  
400 407
    def _get_account_quotas(self, account):
401 408
        """Get account usage from astakos."""
......
779 786

  
780 787
            # get public
781 788
            objects |= set(self._list_public_object_properties(
782
                user, account, container, prefix, all_props))
789
                user, account, container, prefix, all_props, until))
783 790
            objects = list(objects)
784 791

  
785 792
            objects.sort(key=lambda x: x[0])
786 793
        elif public:
787 794
            objects = self._list_public_object_properties(
788
                user, account, container, prefix, all_props)
795
                user, account, container, prefix, all_props, until)
789 796
        else:
790 797
            allowed = self._list_object_permissions(
791 798
                user, account, container, prefix, shared, public=False)
......
802 809
        return objects[start:start + limit]
803 810

  
804 811
    def _list_public_object_properties(self, user, account, container, prefix,
805
                                       all_props):
812
                                       all_props, until):
806 813
        public = self._list_object_permissions(
807 814
            user, account, container, prefix, shared=False, public=True)
808
        paths, nodes = self._lookup_objects(public)
809
        path = '/'.join((account, container))
810
        cont_prefix = path + '/'
811
        paths = [x[len(cont_prefix):] for x in paths]
812
        objects = [(p,) + props for p, props in
813
                   zip(paths, self.node.version_lookup_bulk(
814
                       nodes, all_props=all_props, order_by_path=True))]
815
        d = self.node.node_lookup_bulk(public)
816
        nodes = d.keys()
817
        cont_prefix = '/'.join((account, container)) + '/'
818
        before = until if until is not None else inf
819
        object_path = lambda p: p[len(cont_prefix):]
820
        slice_props = lambda l: l if all_props else l[:1]
821
        versions = self.node.version_lookup_bulk(nodes, before=before,
822
                                                 all_props=True,
823
                                                 order_by_path=True)
824
        objects = [(object_path(d[p[self.NODE]]),) + slice_props(tuple(p)) for
825
                   p in versions]
815 826
        return objects
816 827

  
817 828
    def _list_objects_no_limit(self, user, account, container, prefix,
......
995 1006
                self.permissions.access_get_for_bulk(access_objects[path])
996 1007
            nobject_permissions[name] = (self.ALLOWED[allowed], path,
997 1008
                                         access_dict)
998
        self._lookup_objects(permissions_path)
1009
        #self._lookup_objects(permissions_path)
999 1010
        return nobject_permissions
1000 1011

  
1001 1012
    @debug_method
......
1518 1529
        return path, node
1519 1530

  
1520 1531
    def _lookup_objects(self, paths):
1521
        nodes = self.node.node_lookup_bulk(paths)
1522
        return paths, nodes
1532
        return self.node.node_lookup_bulk(paths)
1523 1533

  
1524 1534
    def _get_properties(self, node, until=None):
1525 1535
        """Return properties until the timestamp given."""
......
1532 1542
            raise ItemNotExists('Path does not exist')
1533 1543
        return props
1534 1544

  
1545
    def _get_properties_bulk(self, nodes):
1546
        """Return properties for the specified nodes."""
1547

  
1548
        return self.node.version_lookup(nodes, cluster=CLUSTER_NORMAL)
1549

  
1535 1550
    def _get_statistics(self, node, until=None, compute=False):
1536 1551
        """Return (count, sum of size, timestamp) of everything under node."""
1537 1552

  

Also available in: Unified diff