Revision f7667baf

b/pithos/api/functions.py
31 31
# interpreted as representing official policies, either expressed
32 32
# or implied, of GRNET S.A.
33 33

  
34
import os
35 34
import logging
36 35
import hashlib
37 36

  
......
121 120
    if not x_auth_user or not x_auth_key:
122 121
        raise BadRequest('Missing X-Auth-User or X-Auth-Key header')
123 122
    response = HttpResponse(status=204)
123
    
124 124
    inv_auth_tokens = dict((v, k) for k, v in settings.AUTH_TOKENS.items())
125
    uri = request.build_absolute_uri()
126
    if '?' in uri:
127
        uri = uri[:uri.find('?')]
128
    
125 129
    response['X-Auth-Token'] = inv_auth_tokens.get(x_auth_user, '0000')
126
    response['X-Storage-Url'] = os.path.join(request.build_absolute_uri(),
127
                                            x_auth_user)
130
    response['X-Storage-Url'] = uri + (uri.endswith('/') and '' or '/') + x_auth_user
128 131
    return response
129 132

  
130 133
@api_method('GET', format_allowed=True)
b/pithos/api/tests.py
1273 1273
    def test_move(self):
1274 1274
        #perform move
1275 1275
        meta = {'test':'testcopy'}
1276
        src_path = os.path.join('/', self.containers[0], self.obj['name'])
1276
        src_path = '/'.join(('/', self.containers[0], self.obj['name']))
1277 1277
        status = self.client.move_object(self.containers[0], self.obj['name'],
1278 1278
                                         self.containers[0], 'testcopy',
1279 1279
                                         meta)[0]
......
1510 1510
           'photos/me.jpg']
1511 1511

  
1512 1512
if __name__ == "__main__":
1513
    unittest.main()
1513
    unittest.main()
b/pithos/backends/simple.py
343 343
            raise NameError('Container already exists')
344 344
        if policy:
345 345
            self._check_policy(policy)
346
        path = os.path.join(account, container)
346
        path = '/'.join((account, container))
347 347
        version_id = self._put_version(path, user)[0]
348 348
        for k, v in self.default_policy.iteritems():
349 349
            if k not in policy:
......
388 388
        if user != account:
389 389
            if until:
390 390
                raise NotAllowedError
391
            allowed = self._allowed_paths(user, os.path.join(account, container))
391
            allowed = self._allowed_paths(user, '/'.join((account, container)))
392 392
            if not allowed:
393 393
                raise NotAllowedError
394 394
        else:
395 395
            if shared:
396
                allowed = self._shared_paths(os.path.join(account, container))
396
                allowed = self._shared_paths('/'.join((account, container)))
397 397
        path, version_id, mtime = self._get_containerinfo(account, container, until)
398 398
        return self._list_objects(path, prefix, delimiter, marker, limit, virtual, keys, until, allowed)
399 399
    
......
406 406
        if user != account:
407 407
            if until:
408 408
                raise NotAllowedError
409
            allowed = self._allowed_paths(user, os.path.join(account, container))
409
            allowed = self._allowed_paths(user, '/'.join((account, container)))
410 410
            if not allowed:
411 411
                raise NotAllowedError
412 412
        path, version_id, mtime = self._get_containerinfo(account, container, until)
......
513 513
            ie.data = missing
514 514
            raise ie
515 515
        path = self._get_containerinfo(account, container)[0]
516
        path = os.path.join(path, name)
516
        path = '/'.join((path, name))
517 517
        if permissions is not None:
518 518
            r, w = self._check_permissions(path, permissions)
519 519
        src_version_id, dest_version_id = self._copy_version(user, path, path, not replace_meta, False)
......
539 539
        if src_version is None:
540 540
            src_path = self._get_objectinfo(account, src_container, src_name)[0]
541 541
        else:
542
            src_path = os.path.join(account, src_container, src_name)
542
            src_path = '/'.join((account, src_container, src_name))
543 543
        dest_path = self._get_containerinfo(account, dest_container)[0]
544
        dest_path = os.path.join(dest_path, dest_name)
544
        dest_path = '/'.join((dest_path, dest_name))
545 545
        if permissions is not None:
546 546
            r, w = self._check_permissions(dest_path, permissions)
547 547
        src_version_id, dest_version_id = self._copy_version(user, src_path, dest_path, not replace_meta, True, src_version)
......
568 568
            raise NotAllowedError
569 569
        
570 570
        if until is not None:
571
            path = os.path.join(account, container, name)
571
            path = '/'.join((account, container, name))
572 572
            sql = '''select version_id from versions where name = ? and tstamp <= ?'''
573 573
            c = self.con.execute(sql, (path, until))
574 574
            for v in [x[0] in c.fetchall()]:
......
592 592
        logger.debug("list_versions: %s %s %s", account, container, name)
593 593
        self._can_read(user, account, container, name)
594 594
        # This will even show deleted versions.
595
        path = os.path.join(account, container, name)
595
        path = '/'.join((account, container, name))
596 596
        sql = '''select distinct version_id, tstamp from versions where name = ? and hide = 0'''
597 597
        c = self.con.execute(sql, (path,))
598 598
        return [(int(x[0]), int(x[1])) for x in c.fetchall()]
......
700 700
            p = p[:p.index(None)]
701 701
        except ValueError:
702 702
            pass
703
        path = os.path.join(*p)
703
        path = '/'.join(p)
704 704
        sql = '''select version_id, tstamp, size from (%s) where name = ?'''
705 705
        sql = sql % self._sql_until(until)
706 706
        c = self.con.execute(sql, (path,))
......
724 724
            raise NameError('Container does not exist')
725 725
    
726 726
    def _get_objectinfo(self, account, container, name, version=None):
727
        path = os.path.join(account, container, name)
727
        path = '/'.join((account, container, name))
728 728
        version_id, muser, mtime, size = self._get_version(path, version)
729 729
        return path, version_id, muser, mtime, size
730 730
    
......
936 936
    def _is_allowed(self, user, account, container, name, op='read'):
937 937
        if user == account:
938 938
            return True
939
        path = os.path.join(account, container, name)
939
        path = '/'.join((account, container, name))
940 940
        if op == 'read' and self._get_public(path):
941 941
            return True
942 942
        perm_path, perms = self._get_permissions(path)
b/pithos/backends/tests.py
118 118
            "modificationDate": 1223372769275,
119 119
            "lastLogin": 1223372769275}
120 120
        self.b.update_account_meta('test', self.account, meta)
121
        p = os.path.join(self.basepath, self.account)
121
        p = '/'.join((self.basepath, self.account))
122 122
        
123 123
        db_meta = self.b.get_account_meta('test', self.account)
124 124
        for k,v in meta.iteritems():

Also available in: Unified diff