

def lock(self):
    '\n        Obtain an editing lock on this dataset.\n        '
    before_lock = self.__class__.objects.get(pk=self.pk)
    self.locked = before_lock.locked
    self.locked_at = before_lock.locked_at
    if self.locked:
        raise DatasetLockedError(_('This dataset is currently locked by another process.'))
    new_locked_at = now()
    self.locked = True
    self.locked_at = new_locked_at
    self.save()
    after_lock = Dataset.objects.get(id=self.id)
    self.locked = after_lock.locked
    self.locked_at = after_lock.locked_at
    if (self.locked_at != new_locked_at):
        raise DatasetLockedError(_('This dataset is currently locked by another process.'))

dataset/ETHPy150Open pandaproject/panda/panda/models/dataset.py Dataset.lock/original