Revision b18ef3ad pithos/backends/simple.py

b/pithos/backends/simple.py
238 238
        self._del_groups(account)
239 239
    
240 240
    @backend_method
241
    def list_containers(self, user, account, marker=None, limit=10000, until=None):
241
    def list_containers(self, user, account, marker=None, limit=10000, shared=False, until=None):
242 242
        """Return a list of containers existing under an account."""
243 243
        
244 244
        logger.debug("list_containers: %s %s %s %s", account, marker, limit, until)
......
248 248
            allowed = self._allowed_containers(user, account)
249 249
            start, limit = self._list_limits(allowed, marker, limit)
250 250
            return allowed[start:start + limit]
251
        else:
252
            if shared:
253
                allowed = [x.split('/', 2)[1] for x in self._shared_paths(account)]
254
                start, limit = self._list_limits(allowed, marker, limit)
255
                return allowed[start:start + limit]
251 256
        return [x[0] for x in self._list_objects(account, '', '/', marker, limit, False, [], until)]
252 257
    
253 258
    @backend_method
......
369 374
        self._copy_version(user, account, account, True, False) # New account version (for timestamp update).
370 375
    
371 376
    @backend_method
372
    def list_objects(self, user, account, container, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, keys=[], until=None):
377
    def list_objects(self, user, account, container, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, keys=[], shared=False, until=None):
373 378
        """Return a list of objects existing under a container."""
374 379
        
375
        logger.debug("list_objects: %s %s %s %s %s %s %s %s %s", account, container, prefix, delimiter, marker, limit, virtual, keys, until)
380
        logger.debug("list_objects: %s %s %s %s %s %s %s %s %s %s", account, container, prefix, delimiter, marker, limit, virtual, keys, shared, until)
376 381
        allowed = []
377 382
        if user != account:
378 383
            if until:
......
380 385
            allowed = self._allowed_paths(user, os.path.join(account, container))
381 386
            if not allowed:
382 387
                raise NotAllowedError
388
        else:
389
            if shared:
390
                allowed = self._shared_paths(os.path.join(account, container))
383 391
        path, version_id, mtime = self._get_containerinfo(account, container, until)
384 392
        return self._list_objects(path, prefix, delimiter, marker, limit, virtual, keys, until, allowed)
385 393
    
......
970 978
        for path in self._allowed_paths(user, account):
971 979
            allow.add(path.split('/', 2)[1])
972 980
        return sorted(allow)
981
    
982
    def _shared_paths(self, prefix):
983
        sql = 'select distinct name from permissions where name like ?'
984
        c = self.con.execute(sql, (prefix + '/%',))
985
        return [x[0] for x in c.fetchall()]

Also available in: Unified diff