Back to index

plone3  3.1.7
events.py
Go to the documentation of this file.
00001 from zope.interface import implements
00002 
00003 from plone.locking.interfaces import ILockable
00004 
00005 # These event handlers are not connected by default, but can be used for
00006 # a particular object event (used e.g. in Archetypes)
00007 
00008 def lockOnEditBegins(obj, event):
00009     """Lock the object when a user start working on the object
00010     """
00011     lockable = ILockable(obj)
00012     if not lockable.locked():
00013         lockable.lock()
00014 
00015 def unlockAfterModification(obj, event):
00016     """Release the DAV lock after save
00017     """
00018     lockable = ILockable(obj)
00019     if lockable.can_safely_unlock():
00020         lockable.unlock()