# Path: libre/apps/lock_manager/models.py
# class Lock(models.Model):
#     creation_datetime = models.DateTimeField(verbose_name=_(u'creation datetime'))
#     timeout = models.IntegerField(default=DEFAULT_LOCK_TIMEOUT_VALUE, verbose_name=_(u'timeout'))
#     name = models.CharField(max_length=48, verbose_name=_(u'name'), unique=True)
# 
#     objects = LockManager()
# 
#     def __unicode__(self):
#         return self.name
# 
#     def save(self, *args, **kwargs):
#         self.creation_datetime = now()
#         if not self.timeout and not kwargs.get('timeout'):
#             self.timeout = DEFAULT_LOCK_TIMEOUT_VALUE
# 
#         super(Lock, self).save(*args, **kwargs)
# 
#     @transaction.commit_on_success
#     def release(self):
#         try:
#             logger.debug('trying to release lock: %s' % self.name)
#             lock = Lock.objects.get(name=self.name, creation_datetime=self.creation_datetime)
#             lock.delete()
#         except Lock.DoesNotExist:
#             # Lock expired and was reassigned
#             logger.debug('lock: %s, had expired' % self.name)
#             pass
#         except DatabaseError:
#             transaction.rollback()
#         else:
#             logger.debug('lock: %s, released' % self.name)
# 
#     class Meta:
#         verbose_name = _(u'lock')
#         verbose_name_plural = _(u'locks')


from django.contrib import admin
from .models import Lock
from __future__ import absolute_import




class LockAdmin(admin.ModelAdmin):
    model = Lock



# Path: libre/apps/lock_manager/models.py
# class Lock(models.Model):
#     creation_datetime = models.DateTimeField(verbose_name=_(u'creation datetime'))
#     timeout = models.IntegerField(default=DEFAULT_LOCK_TIMEOUT_VALUE, verbose_name=_(u'timeout'))
#     name = models.CharField(max_length=48, verbose_name=_(u'name'), unique=True)
# 
#     objects = LockManager()
# 
#     def __unicode__(self):
#         return self.name
# 
#     def save(self, *args, **kwargs):
#         self.creation_datetime = now()
#         if not self.timeout and not kwargs.get('timeout'):
#             self.timeout = DEFAULT_LOCK_TIMEOUT_VALUE
# 
#         super(Lock, self).save(*args, **kwargs)
# 
#     @transaction.commit_on_success
#     def release(self):
#         try:
#             logger.debug('trying to release lock: %s' % self.name)
#             lock = Lock.objects.get(name=self.name, creation_datetime=self.creation_datetime)
#             lock.delete()
#         except Lock.DoesNotExist:
#             # Lock expired and was reassigned
#             logger.debug('lock: %s, had expired' % self.name)
#             pass
#         except DatabaseError:
#             transaction.rollback()
#         else:
#             logger.debug('lock: %s, released' % self.name)
# 
#     class Meta:
#         verbose_name = _(u'lock')
#         verbose_name_plural = _(u'locks')


# Path: libre/apps/lock_manager/admin.py
from django.contrib import admin
from .models import Lock

from __future__ import absolute_import




class LockAdmin(admin.ModelAdmin):
    model = Lock



admin.site.register(Lock, LockAdmin)