Beispiel #1
0
 def delete_item(self, item):
     try:
         self._itemdb.delete(
             pack_value(item._pid) + b'_' + pack_value(item._id),
             context._trans.txn)
     except (db.DBLockDeadlockError, db.DBLockNotGrantedError):
         context._trans.abort()
         raise exceptions.DBRetryTransaction
Beispiel #2
0
 def delete_item(self, item):
     try:
         self._itemdb.delete(
             pack_value(item._pid) + b'_' + pack_value(item._id),
             context._trans.txn)
     except (db.DBLockDeadlockError, db.DBLockNotGrantedError):
         context._trans.abort()
         raise exceptions.DBRetryTransaction
Beispiel #3
0
 def get_child_by_name(self, container_id, name):
     try:
         return self._indices['displayName'].db.get(
             pack_value(container_id) + b'_' + pack_value(name),
             txn=context._trans and context._trans.txn)
     except (db.DBLockDeadlockError, db.DBLockNotGrantedError):
         if context._trans is not None:
             context._trans.abort()
         raise exceptions.DBRetryTransaction
Beispiel #4
0
 def get_child_by_name(self, container_id, name):
     try:
         return self._indices['displayName'].db.get(
             pack_value(container_id) + b'_' + pack_value(name),
             txn=context._trans and context._trans.txn)
     except (db.DBLockDeadlockError, db.DBLockNotGrantedError):
         if context._trans is not None:
             context._trans.abort()
         raise exceptions.DBRetryTransaction
Beispiel #5
0
 def put_item(self, item):
     try:
         self._itemdb.put(
             pack_value(item._pid) + b'_' + pack_value(item._id),
             persist.dumps(item), context._trans.txn)
     except (db.DBLockDeadlockError, db.DBLockNotGrantedError):
         context._trans.abort()
         raise exceptions.DBRetryTransaction
     except db.DBError as e:
         if e.args[0] == _err_unsupported_index_type:
             raise db.DBError('Unsupported indexed data type')
         else:
             raise
Beispiel #6
0
 def put_item(self, item):
     try:
         self._itemdb.put(
             pack_value(item._pid) + b'_' + pack_value(item._id),
             persist.dumps(item),
             context._trans.txn)
     except (db.DBLockDeadlockError, db.DBLockNotGrantedError):
         context._trans.abort()
         raise exceptions.DBRetryTransaction
     except db.DBError as e:
         if e.args[0] == _err_unsupported_index_type:
             raise db.DBError('Unsupported indexed data type')
         else:
             raise
Beispiel #7
0
 def set_lower_bound(self, lower_bound):
     if lower_bound is not None:
         value, inclusive = lower_bound
         self._lower_value = pack_value(value)
         self._lower_inclusive = inclusive
     else:
         self._lower_value = None
         self._lower_inclusive = False
Beispiel #8
0
 def set_upper_bound(self, upper_bound):
     if upper_bound is not None:
         value, inclusive = upper_bound
         self._upper_value = pack_value(value)
         self._upper_inclusive = inclusive
     else:
         self._upper_value = None
         self._upper_inclusive = False
Beispiel #9
0
 def set_lower_bound(self, lower_bound):
     if lower_bound is not None:
         value, inclusive = lower_bound
         self._lower_value = pack_value(value)
         self._lower_inclusive = inclusive
     else:
         self._lower_value = None
         self._lower_inclusive = False
Beispiel #10
0
 def set_upper_bound(self, upper_bound):
     if upper_bound is not None:
         value, inclusive = upper_bound
         self._upper_value = pack_value(value)
         self._upper_inclusive = inclusive
     else:
         self._upper_value = None
         self._upper_inclusive = False
 def callback(key, value):
     item = _cache.get(value, persist.loads(value))
     index_value = None
     if item._isDeleted and not self.name == "_id":
         # do not index attributes of deleted objects
         return None
     if self.name == "_id" or (hasattr(item, self.name) and hasattr(item, "_owner")):
         # if item is composite index only the _id attribute
         # otherwise allow indexing of all
         attr = getattr(item, self.name)
         if attr.__class__.__module__ != None.__class__.__module__:
             attr = attr.value
         if self.name == "_id":
             index_value = pack_value(attr)
         else:
             index_value = pack_value(item._pid) + b"_" + pack_value(attr)
     _cache[value] = item
     return index_value
Beispiel #12
0
 def callback(key, value):
     item = _cache.get(value, persist.loads(value))
     index_value = None
     if item._isDeleted and not self.name == '_id':
         # do not index attributes of deleted objects
         return None
     if self.name == '_id' or \
             (hasattr(item, self.name) and hasattr(item, '_owner')):
         # if item is composite index only the _id attribute
         # otherwise allow indexing of all
         attr = getattr(item, self.name)
         if attr.__class__.__module__ != None.__class__.__module__:
             attr = attr.value
         if self.name == '_id':
             index_value = pack_value(attr)
         else:
             index_value = (pack_value(item._pid) + b'_' +
                            pack_value(attr))
     _cache[value] = item
     return index_value
Beispiel #13
0
 def _eval(self, item):
     if hasattr(item, self.name):
         attr = getattr(item, self.name)
         if attr.__class__.__module__ != None.__class__.__module__:
             attr = attr.value
         packed = pack_value(attr)
         if self._value is not None:
             return self._value == packed
         else:
             return packed in self._range
     return False
Beispiel #14
0
 def _eval(self, item):
     if hasattr(item, self.name):
         attr = getattr(item, self.name)
         if attr.__class__.__module__ != None.__class__.__module__:
             attr = attr.value
         packed = pack_value(attr)
         if self._value is not None:
             return self._value == packed
         else:
             return packed in self._range
     return False
Beispiel #15
0
 def set(self, v):
     val = pack_value(v)
     self._value = val
     self._range = None
Beispiel #16
0
 def set(self, v):
     val = pack_value(v)
     self._value = val
     self._range = None