Back to index

plone3  3.1.7
lock.py
Go to the documentation of this file.
00001 # -*- coding: UTF-8 -*-
00002 from zope.interface import implements
00003 from plonekssview import PloneKSSView
00004 from kss.core import kssaction
00005 from interfaces import IPloneKSSView
00006 from plone.locking.interfaces import ILockable
00007 from Acquisition import aq_inner
00008 from zope.component import queryAdapter
00009 
00010 class LockView(PloneKSSView):
00011     """
00012     Lock informations/operation in kss
00013     """
00014     implements(IPloneKSSView)
00015 
00016     @kssaction
00017     def updateLockInfo(self):
00018         """Update the lock icon -
00019         Check if the object if really locked before showing the icon
00020         an xmlhttprequest might have just been sent on the object to
00021         unlock just a few moment ago. So we need to be really sure
00022         that the object wasn't locked, to be sure, we do one more
00023         """
00024         context = aq_inner(self.context)
00025         locking = queryAdapter(context, ILockable)
00026         if locking and not locking.locked():
00027             coreCmd = self.getCommandSet('core')
00028             selector = coreCmd.getHtmlIdSelector('lock-icon')
00029             coreCmd.deleteNode(selector)