1 # Copyright 2011 GRNET S.A. All rights reserved.
3 # Redistribution and use in source and binary forms, with or
4 # without modification, are permitted provided that the following
7 # 1. Redistributions of source code must retain the above
8 # copyright notice, this list of conditions and the following
11 # 2. Redistributions in binary form must reproduce the above
12 # copyright notice, this list of conditions and the following
13 # disclaimer in the documentation and/or other materials
14 # provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
29 # The views and conclusions contained in the software and
30 # documentation are those of the authors and should not be
31 # interpreted as representing official policies, either expressed
32 # or implied, of GRNET S.A.
43 from base import NotAllowedError, BaseBackend
46 logger = logging.getLogger(__name__)
49 class SimpleBackend(BaseBackend):
52 Uses SQLite for storage.
55 # TODO: Automatic/manual clean-up after a time interval.
57 def __init__(self, db):
58 self.hash_algorithm = 'sha1'
59 self.block_size = 128 * 1024 # 128KB
61 basepath = os.path.split(db)[0]
62 if basepath and not os.path.exists(basepath):
65 self.con = sqlite3.connect(db, check_same_thread=False)
66 sql = '''create table if not exists versions (
67 version_id integer primary key,
70 tstamp datetime default current_timestamp,
71 size integer default 0,
72 hide integer default 0)'''
74 sql = '''create table if not exists metadata (
75 version_id integer, key text, value text, primary key (version_id, key))'''
77 sql = '''create table if not exists blocks (
78 block_id text, data blob, primary key (block_id))'''
80 sql = '''create table if not exists hashmaps (
81 version_id integer, pos integer, block_id text, primary key (version_id, pos))'''
83 sql = '''create table if not exists groups (
84 account text, name text, users text, primary key (account, name))'''
86 sql = '''create table if not exists permissions (
87 name text, read text, write text, primary key (name))'''
89 sql = '''create table if not exists policy (
90 name text, key text, value text, primary key (name, key))'''
94 def get_account_meta(self, user, account, until=None):
95 """Return a dictionary with the account metadata."""
97 logger.debug("get_account_meta: %s %s", account, until)
101 version_id, mtime = self._get_accountinfo(account, until)
105 count, bytes, tstamp = self._get_pathstats(account, until)
111 modified = self._get_pathstats(account)[2] # Overall last modification
116 sql = 'select count(name) from (%s) where name glob ? and not name glob ?'
117 sql = sql % self._sql_until(until)
118 c = self.con.execute(sql, (account + '/*', account + '/*/*'))
122 meta = self._get_metadata(account, version_id)
123 meta.update({'name': account, 'count': count, 'bytes': bytes})
125 meta.update({'modified': modified})
126 if until is not None:
127 meta.update({'until_timestamp': tstamp})
130 def update_account_meta(self, user, account, meta, replace=False):
131 """Update the metadata associated with the account."""
133 logger.debug("update_account_meta: %s %s %s", account, meta, replace)
135 raise NotAllowedError
136 self._put_metadata(user, account, meta, replace)
138 def get_account_groups(self, user, account):
139 """Return a dictionary with the user groups defined for this account."""
141 logger.debug("get_account_groups: %s", account)
143 raise NotAllowedError
144 return self._get_groups(account)
146 def update_account_groups(self, user, account, groups, replace=False):
147 """Update the groups associated with the account."""
149 logger.debug("update_account_groups: %s %s %s", account, groups, replace)
151 raise NotAllowedError
152 for k, v in groups.iteritems():
153 if True in [False or ',' in x for x in v]:
154 raise ValueError('Bad characters in groups')
156 sql = 'delete from groups where account = ?'
157 self.con.execute(sql, (account,))
158 for k, v in groups.iteritems():
161 sql = 'delete from groups where account = ? and name = ?'
162 self.con.execute(sql, (account, k))
164 sql = 'insert or replace into groups (account, name, users) values (?, ?, ?)'
165 self.con.execute(sql, (account, k, ','.join(v)))
168 def delete_account(self, user, account):
169 """Delete the account with the given name."""
171 logger.debug("delete_account: %s", account)
173 raise NotAllowedError
174 count, bytes, tstamp = self._get_pathstats(account)
176 raise IndexError('Account is not empty')
177 self._del_path(account) # Point of no return.
179 def list_containers(self, user, account, marker=None, limit=10000, until=None):
180 """Return a list of containers existing under an account."""
182 logger.debug("list_containers: %s %s %s %s", account, marker, limit, until)
184 raise NotAllowedError
185 return self._list_objects(account, '', '/', marker, limit, False, [], until)
187 def get_container_meta(self, user, account, container, until=None):
188 """Return a dictionary with the container metadata."""
190 logger.debug("get_container_meta: %s %s %s", account, container, until)
192 raise NotAllowedError
193 path, version_id, mtime = self._get_containerinfo(account, container, until)
194 count, bytes, tstamp = self._get_pathstats(path, until)
200 modified = self._get_pathstats(path)[2] # Overall last modification
204 meta = self._get_metadata(path, version_id)
205 meta.update({'name': container, 'count': count, 'bytes': bytes, 'modified': modified})
206 if until is not None:
207 meta.update({'until_timestamp': tstamp})
210 def update_container_meta(self, user, account, container, meta, replace=False):
211 """Update the metadata associated with the container."""
213 logger.debug("update_container_meta: %s %s %s %s", account, container, meta, replace)
215 raise NotAllowedError
216 path, version_id, mtime = self._get_containerinfo(account, container)
217 self._put_metadata(user, path, meta, replace)
219 def get_container_policy(self, user, account, container):
220 """Return a dictionary with the container policy."""
222 logger.debug("get_container_policy: %s %s", account, container)
225 def update_container_policy(self, user, account, container, policy, replace=False):
226 """Update the policy associated with the account."""
228 logger.debug("update_container_policy: %s %s %s %s", account, container, policy, replace)
231 def put_container(self, user, account, container, policy=None):
232 """Create a new container with the given name."""
234 logger.debug("put_container: %s %s %s", account, container, policy)
236 raise NotAllowedError
238 path, version_id, mtime = self._get_containerinfo(account, container)
240 path = os.path.join(account, container)
241 version_id = self._put_version(path, user)
243 raise NameError('Container already exists')
245 def delete_container(self, user, account, container):
246 """Delete the container with the given name."""
248 logger.debug("delete_container: %s %s", account, container)
250 raise NotAllowedError
251 path, version_id, mtime = self._get_containerinfo(account, container)
252 count, bytes, tstamp = self._get_pathstats(path)
254 raise IndexError('Container is not empty')
255 self._del_path(path) # Point of no return.
256 self._copy_version(user, account, account, True, True) # New account version.
258 def list_objects(self, user, account, container, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, keys=[], until=None):
259 """Return a list of objects existing under a container."""
261 logger.debug("list_objects: %s %s %s %s %s %s %s", account, container, prefix, delimiter, marker, limit, until)
263 raise NotAllowedError
264 path, version_id, mtime = self._get_containerinfo(account, container, until)
265 return self._list_objects(path, prefix, delimiter, marker, limit, virtual, keys, until)
267 def list_object_meta(self, user, account, container, until=None):
268 """Return a list with all the container's object meta keys."""
270 logger.debug("list_object_meta: %s %s %s", account, container, until)
272 raise NotAllowedError
273 path, version_id, mtime = self._get_containerinfo(account, container, until)
274 sql = '''select distinct m.key from (%s) o, metadata m
275 where m.version_id = o.version_id and o.name like ?'''
276 sql = sql % self._sql_until(until)
277 c = self.con.execute(sql, (path + '/%',))
278 return [x[0] for x in c.fetchall()]
280 def get_object_meta(self, user, account, container, name, version=None):
281 """Return a dictionary with the object metadata."""
283 logger.debug("get_object_meta: %s %s %s %s", account, container, name, version)
284 self._can_read(user, account, container, name)
285 path, version_id, muser, mtime, size = self._get_objectinfo(account, container, name, version)
289 modified = self._get_version(path, version)[2] # Overall last modification
291 meta = self._get_metadata(path, version_id)
292 meta.update({'name': name, 'bytes': size})
293 meta.update({'version': version_id, 'version_timestamp': mtime})
294 meta.update({'modified': modified, 'modified_by': muser})
297 def update_object_meta(self, user, account, container, name, meta, replace=False):
298 """Update the metadata associated with the object."""
300 logger.debug("update_object_meta: %s %s %s %s %s", account, container, name, meta, replace)
301 self._can_write(user, account, container, name)
302 path, version_id, muser, mtime, size = self._get_objectinfo(account, container, name)
303 self._put_metadata(user, path, meta, replace)
305 def get_object_permissions(self, user, account, container, name):
306 """Return the path from which this object gets its permissions from,\
307 along with a dictionary containing the permissions."""
309 logger.debug("get_object_permissions: %s %s %s", account, container, name)
310 self._can_read(user, account, container, name)
311 path = self._get_objectinfo(account, container, name)[0]
312 return self._get_permissions(path)
314 def update_object_permissions(self, user, account, container, name, permissions):
315 """Update the permissions associated with the object."""
317 logger.debug("update_object_permissions: %s %s %s %s", account, container, name, permissions)
319 raise NotAllowedError
320 path = self._get_objectinfo(account, container, name)[0]
321 r, w = self._check_permissions(path, permissions)
322 self._put_permissions(path, r, w)
324 def get_object_public(self, user, account, container, name):
325 """Return the public URL of the object if applicable."""
327 logger.debug("get_object_public: %s %s %s", account, container, name)
330 def update_object_public(self, user, account, container, name, public):
331 """Update the public status of the object."""
333 logger.debug("update_object_public: %s %s %s %s", account, container, name, public)
336 def get_object_hashmap(self, user, account, container, name, version=None):
337 """Return the object's size and a list with partial hashes."""
339 logger.debug("get_object_hashmap: %s %s %s %s", account, container, name, version)
340 self._can_read(user, account, container, name)
341 path, version_id, muser, mtime, size = self._get_objectinfo(account, container, name, version)
342 sql = 'select block_id from hashmaps where version_id = ? order by pos asc'
343 c = self.con.execute(sql, (version_id,))
344 hashmap = [x[0] for x in c.fetchall()]
347 def update_object_hashmap(self, user, account, container, name, size, hashmap, meta={}, replace_meta=False, permissions=None):
348 """Create/update an object with the specified size and partial hashes."""
350 logger.debug("update_object_hashmap: %s %s %s %s %s", account, container, name, size, hashmap)
351 if permissions is not None and user != account:
352 raise NotAllowedError
353 self._can_write(user, account, container, name)
355 for i in range(len(hashmap)):
356 sql = 'select count(*) from blocks where block_id = ?'
357 c = self.con.execute(sql, (hashmap[i],))
358 if c.fetchone()[0] == 0:
359 missing.append(hashmap[i])
364 path = self._get_containerinfo(account, container)[0]
365 path = os.path.join(path, name)
366 if permissions is not None:
367 r, w = self._check_permissions(path, permissions)
368 src_version_id, dest_version_id = self._copy_version(user, path, path, not replace_meta, False)
369 sql = 'update versions set size = ? where version_id = ?'
370 self.con.execute(sql, (size, dest_version_id))
371 # TODO: Check for block_id existence.
372 for i in range(len(hashmap)):
373 sql = 'insert or replace into hashmaps (version_id, pos, block_id) values (?, ?, ?)'
374 self.con.execute(sql, (dest_version_id, i, hashmap[i]))
375 for k, v in meta.iteritems():
376 sql = 'insert or replace into metadata (version_id, key, value) values (?, ?, ?)'
377 self.con.execute(sql, (dest_version_id, k, v))
378 if permissions is not None:
379 sql = 'insert or replace into permissions (name, read, write) values (?, ?, ?)'
380 self.con.execute(sql, (path, r, w))
383 def copy_object(self, user, account, src_container, src_name, dest_container, dest_name, dest_meta={}, replace_meta=False, permissions=None, src_version=None):
384 """Copy an object's data and metadata."""
386 logger.debug("copy_object: %s %s %s %s %s %s %s %s %s", account, src_container, src_name, dest_container, dest_name, dest_meta, replace_meta, permissions, src_version)
387 if permissions is not None and user != account:
388 raise NotAllowedError
389 self._can_read(user, account, src_container, src_name)
390 self._can_write(user, account, dest_container, dest_name)
391 self._get_containerinfo(account, src_container)
392 if src_version is None:
393 src_path = self._get_objectinfo(account, src_container, src_name)[0]
395 src_path = os.path.join(account, src_container, src_name)
396 dest_path = self._get_containerinfo(account, dest_container)[0]
397 dest_path = os.path.join(dest_path, dest_name)
398 if permissions is not None:
399 r, w = self._check_permissions(dest_path, permissions)
400 src_version_id, dest_version_id = self._copy_version(user, src_path, dest_path, not replace_meta, True, src_version)
401 for k, v in dest_meta.iteritems():
402 sql = 'insert or replace into metadata (version_id, key, value) values (?, ?, ?)'
403 self.con.execute(sql, (dest_version_id, k, v))
404 if permissions is not None:
405 sql = 'insert or replace into permissions (name, read, write) values (?, ?, ?)'
406 self.con.execute(sql, (dest_path, r, w))
409 def move_object(self, user, account, src_container, src_name, dest_container, dest_name, dest_meta={}, replace_meta=False, permissions=None):
410 """Move an object's data and metadata."""
412 logger.debug("move_object: %s %s %s %s %s %s %s %s", account, src_container, src_name, dest_container, dest_name, dest_meta, replace_meta, permissions)
413 self.copy_object(user, account, src_container, src_name, dest_container, dest_name, dest_meta, replace_meta, permissions, None)
414 self.delete_object(user, account, src_container, src_name)
416 def delete_object(self, user, account, container, name):
417 """Delete an object."""
419 logger.debug("delete_object: %s %s %s", account, container, name)
421 raise NotAllowedError
422 path = self._get_objectinfo(account, container, name)[0]
423 self._put_version(path, user, 0, 1)
424 sql = 'delete from permissions where name = ?'
425 self.con.execute(sql, (path,))
428 def list_versions(self, user, account, container, name):
429 """Return a list of all (version, version_timestamp) tuples for an object."""
431 logger.debug("list_versions: %s %s %s", account, container, name)
432 self._can_read(user, account, container, name)
433 # This will even show deleted versions.
434 path = os.path.join(account, container, name)
435 sql = '''select distinct version_id, strftime('%s', tstamp) from versions where name = ? and hide = 0'''
436 c = self.con.execute(sql, (path,))
437 return [(int(x[0]), int(x[1])) for x in c.fetchall()]
439 def get_block(self, hash):
440 """Return a block's data."""
442 logger.debug("get_block: %s", hash)
443 c = self.con.execute('select data from blocks where block_id = ?', (hash,))
448 raise NameError('Block does not exist')
450 def put_block(self, data):
451 """Create a block and return the hash."""
453 logger.debug("put_block: %s", len(data))
454 h = hashlib.new(self.hash_algorithm)
455 h.update(data.rstrip('\x00'))
457 sql = 'insert or ignore into blocks (block_id, data) values (?, ?)'
458 self.con.execute(sql, (hash, buffer(data)))
462 def update_block(self, hash, data, offset=0):
463 """Update a known block and return the hash."""
465 logger.debug("update_block: %s %s %s", hash, len(data), offset)
466 if offset == 0 and len(data) == self.block_size:
467 return self.put_block(data)
468 src_data = self.get_block(hash)
470 if offset < 0 or offset > bs or offset + len(data) > bs:
471 raise IndexError('Offset or data outside block limits')
472 dest_data = src_data[:offset] + data + src_data[offset + len(data):]
473 return self.put_block(dest_data)
475 def _sql_until(self, until=None):
476 """Return the sql to get the latest versions until the timestamp given."""
478 until = int(time.time())
479 sql = '''select version_id, name, strftime('%s', tstamp) as tstamp, size from versions v
480 where version_id = (select max(version_id) from versions
481 where v.name = name and tstamp <= datetime(%s, 'unixepoch'))
483 return sql % ('%s', until)
485 def _get_pathstats(self, path, until=None):
486 """Return count and sum of size of everything under path and latest timestamp."""
488 sql = 'select count(version_id), total(size), max(tstamp) from (%s) where name like ?'
489 sql = sql % self._sql_until(until)
490 c = self.con.execute(sql, (path + '/%',))
492 tstamp = row[2] if row[2] is not None else 0
493 return int(row[0]), int(row[1]), int(tstamp)
495 def _get_version(self, path, version=None):
497 sql = '''select version_id, user, strftime('%s', tstamp), size, hide from versions where name = ?
498 order by version_id desc limit 1'''
499 c = self.con.execute(sql, (path,))
501 if not row or int(row[4]):
502 raise NameError('Object does not exist')
504 # The database (sqlite) will not complain if the version is not an integer.
505 sql = '''select version_id, user, strftime('%s', tstamp), size from versions where name = ?
506 and version_id = ?'''
507 c = self.con.execute(sql, (path, version))
510 raise IndexError('Version does not exist')
511 return str(row[0]), str(row[1]), int(row[2]), int(row[3])
513 def _put_version(self, path, user, size=0, hide=0):
514 sql = 'insert into versions (name, user, size, hide) values (?, ?, ?, ?)'
515 id = self.con.execute(sql, (path, user, size, hide)).lastrowid
519 def _copy_version(self, user, src_path, dest_path, copy_meta=True, copy_data=True, src_version=None):
520 if src_version is not None:
521 src_version_id, muser, mtime, size = self._get_version(src_path, src_version)
523 # Latest or create from scratch.
525 src_version_id, muser, mtime, size = self._get_version(src_path)
527 src_version_id = None
531 dest_version_id = self._put_version(dest_path, user, size)
532 if copy_meta and src_version_id is not None:
533 sql = 'insert into metadata select %s, key, value from metadata where version_id = ?'
534 sql = sql % dest_version_id
535 self.con.execute(sql, (src_version_id,))
536 if copy_data and src_version_id is not None:
537 sql = 'insert into hashmaps select %s, pos, block_id from hashmaps where version_id = ?'
538 sql = sql % dest_version_id
539 self.con.execute(sql, (src_version_id,))
541 return src_version_id, dest_version_id
543 def _get_versioninfo(self, account, container, name, until=None):
544 """Return path, latest version, associated timestamp and size until the timestamp given."""
546 p = (account, container, name)
548 p = p[:p.index(None)]
551 path = os.path.join(*p)
552 sql = '''select version_id, tstamp, size from (%s) where name = ?'''
553 sql = sql % self._sql_until(until)
554 c = self.con.execute(sql, (path,))
557 raise NameError('Path does not exist')
558 return path, str(row[0]), int(row[1]), int(row[2])
560 def _get_accountinfo(self, account, until=None):
562 path, version_id, mtime, size = self._get_versioninfo(account, None, None, until)
563 return version_id, mtime
565 raise NameError('Account does not exist')
567 def _get_containerinfo(self, account, container, until=None):
569 path, version_id, mtime, size = self._get_versioninfo(account, container, None, until)
570 return path, version_id, mtime
572 raise NameError('Container does not exist')
574 def _get_objectinfo(self, account, container, name, version=None):
575 path = os.path.join(account, container, name)
576 version_id, muser, mtime, size = self._get_version(path, version)
577 return path, version_id, muser, mtime, size
579 def _get_metadata(self, path, version):
580 sql = 'select key, value from metadata where version_id = ?'
581 c = self.con.execute(sql, (version,))
582 return dict(c.fetchall())
584 def _put_metadata(self, user, path, meta, replace=False):
585 """Create a new version and store metadata."""
587 src_version_id, dest_version_id = self._copy_version(user, path, path, not replace, True)
588 for k, v in meta.iteritems():
589 if not replace and v == '':
590 sql = 'delete from metadata where version_id = ? and key = ?'
591 self.con.execute(sql, (dest_version_id, k))
593 sql = 'insert or replace into metadata (version_id, key, value) values (?, ?, ?)'
594 self.con.execute(sql, (dest_version_id, k, v))
597 def _get_groups(self, account):
598 sql = 'select name, users from groups where account = ?'
599 c = self.con.execute(sql, (account,))
600 return dict([(x[0], x[1].split(',')) for x in c.fetchall()])
602 def _is_allowed(self, user, account, container, name, op='read'):
605 path = os.path.join(account, container, name)
606 perm_path, perms = self._get_permissions(path)
609 for x in ('read', 'write'):
611 for y in perms.get(x, []):
613 g_account, g_name = y.split(':', 1)
614 groups = self._get_groups(g_account)
616 g_perms += groups[g_name]
621 if op == 'read' and user in perms.get('read', []):
623 if user in perms.get('write', []):
627 def _can_read(self, user, account, container, name):
628 if not self._is_allowed(user, account, container, name, 'read'):
629 raise NotAllowedError
631 def _can_write(self, user, account, container, name):
632 if not self._is_allowed(user, account, container, name, 'write'):
633 raise NotAllowedError
635 def _check_permissions(self, path, permissions):
636 # Check for existing permissions.
637 sql = '''select name from permissions
638 where name != ? and (name like ? or ? like name || ?)'''
639 c = self.con.execute(sql, (path, path + '%', path, '%'))
642 raise AttributeError('Permissions already set')
644 # Format given permissions.
645 if len(permissions) == 0:
647 r = permissions.get('read', [])
648 w = permissions.get('write', [])
649 if True in [False or ',' in x for x in r]:
650 raise ValueError('Bad characters in read permissions')
651 if True in [False or ',' in x for x in w]:
652 raise ValueError('Bad characters in write permissions')
653 return ','.join(r), ','.join(w)
655 def _get_permissions(self, path):
656 # Check for permissions at path or above.
657 sql = 'select name, read, write from permissions where ? like name || ?'
658 c = self.con.execute(sql, (path, '%'))
666 ret['write'] = w.split(',')
668 ret['read'] = r.split(',')
671 def _put_permissions(self, path, r, w):
672 if r == '' and w == '':
673 sql = 'delete from permissions where name = ?'
674 self.con.execute(sql, (path,))
676 sql = 'insert or replace into permissions (name, read, write) values (?, ?, ?)'
677 self.con.execute(sql, (path, r, w))
680 def _list_objects(self, path, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, keys=[], until=None):
681 cont_prefix = path + '/'
682 if keys and len(keys) > 0:
683 sql = '''select distinct o.name, o.version_id from (%s) o, metadata m where o.name like ? and
684 m.version_id = o.version_id and m.key in (%s) order by o.name'''
685 sql = sql % (self._sql_until(until), ', '.join('?' * len(keys)))
686 param = (cont_prefix + prefix + '%',) + tuple(keys)
688 sql = 'select name, version_id from (%s) where name like ? order by name'
689 sql = sql % self._sql_until(until)
690 param = (cont_prefix + prefix + '%',)
691 c = self.con.execute(sql, param)
692 objects = [(x[0][len(cont_prefix):], x[1]) for x in c.fetchall()]
697 i = pseudo_name.find(delimiter, len(prefix))
699 # If the delimiter is not found, or the name ends
700 # with the delimiter's first occurence.
701 if i == -1 or len(pseudo_name) == i + len(delimiter):
702 pseudo_objects.append(x)
704 # If the delimiter is found, keep up to (and including) the delimiter.
706 pseudo_name = pseudo_name[:i + len(delimiter)]
707 if pseudo_name not in [y[0] for y in pseudo_objects]:
708 if pseudo_name == x[0]:
709 pseudo_objects.append(x)
711 pseudo_objects.append((pseudo_name, None))
712 objects = pseudo_objects
717 start = [x[0] for x in objects].index(marker) + 1
720 if not limit or limit > 10000:
722 return objects[start:start + limit]
724 def _del_path(self, path):
725 sql = '''delete from hashmaps where version_id in
726 (select version_id from versions where name = ?)'''
727 self.con.execute(sql, (path,))
728 sql = '''delete from metadata where version_id in
729 (select version_id from versions where name = ?)'''
730 self.con.execute(sql, (path,))
731 sql = '''delete from versions where name = ?'''
732 self.con.execute(sql, (path,))
733 sql = '''delete from permissions where name like ?'''
734 self.con.execute(sql, (path + '%',)) # Redundant.