def delete(self): """ Decrease the ref count with 1. @return int Returns the current ref count. If it is below 1 than the physical file has to be removed also """ try: self.getPrimaryKey() except ValueError: raise ValueError( 'The id key must be set in order to delete Meta record') self.ref_count = self.ref_count - 1 if self.ref_count < 1: ActiveRecord.delete(self) else: ActiveRecord.save(self) return self.ref_count
def delete(self, recursively=False): if recursively: finder = Search(self.db) if not self._data.get('path', None): self.load(True) if not self._data['path']: raise ValueError('Not enough data given') nodes = finder.findByIdPath(self._data['path'], DEPTH_INFINITY) count = 0 for node in nodes: node.delete() count += 1 return count return ActiveRecord.delete(self)