本文整理汇总了Python中plone.locking.interfaces.ILockable.locked方法的典型用法代码示例。如果您正苦于以下问题:Python ILockable.locked方法的具体用法?Python ILockable.locked怎么用?Python ILockable.locked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plone.locking.interfaces.ILockable
的用法示例。
在下文中一共展示了ILockable.locked方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_clear_locks_remove_all_locks_on_the_object
# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import locked [as 别名]
def test_clear_locks_remove_all_locks_on_the_object(self):
lockable = ILockable(self.wrapper)
lockable.lock()
self.assertTrue(lockable.locked())
lockable.clear_locks()
self.assertFalse(lockable.locked())
示例2: remove_spacesobject_fromsite
# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import locked [as 别名]
def remove_spacesobject_fromsite(portal,logger):
from plone.app.linkintegrity.interfaces import ILinkIntegrityNotificationException
portal_properties=getToolByName(portal, 'portal_properties')
is_link_integrity = portal_properties.site_properties.enable_link_integrity_checks
if is_link_integrity:
portal_properties.site_properties.manage_changeProperties(enable_link_integrity_checks=False)
spaces = None
try:
spaces = getToolByName(portal,'spaces')
if spaces.portal_type != 'SpacesFolder':
spaces = None
except AttributeError:
pass
spacesid = 'spaces'
try:
if spaces <> None:
if callable(spaces.id):
o_id = spaces.id()
else:
o_id = spaces.id
spacesid = o_id
from plone.locking.interfaces import ILockable
lockable = ILockable(spaces)
was_locked = False
if lockable.locked():
was_locked = True
lockable.unlock()
portal.manage_delObjects(ids=[o_id])
logger.info("Deleted spaces object from site.")
transaction.savepoint()
except ILinkIntegrityNotificationException:
pass
recyclebin = getToolByName(portal,'recyclebin')
if recyclebin <> None:
try:
objspaces = getattr(portal,spacesid)
if objspaces.portal_type == 'SpacesFolder':
from plone.locking.interfaces import ILockable
lockable = ILockable(objspaces)
was_locked = False
if lockable.locked():
was_locked = True
lockable.unlock()
recyclebin.manage_delObjects(ids=[spacesid])
logger.info("Deleting spaces object from global recyclebin.")
except AttributeError:
pass
if is_link_integrity:
portal_properties.site_properties.manage_changeProperties(enable_link_integrity_checks=True)
示例3: test_atct_not_lockable
# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import locked [as 别名]
def test_atct_not_lockable(self):
portal = self.layer['portal']
setRoles(portal, TEST_USER_ID, ['Contributor'])
portal.invokeFactory('Document', 'adoc',
title='A title',
description='Some description',
text='Some text')
doc = portal['adoc']
lockable = ILockable(doc)
self.assertEqual(False, lockable.locked())
lockable.lock()
self.assertEqual(False, lockable.locked())
示例4: delete_unwanted_objects_from_memberfolder
# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import locked [as 别名]
def delete_unwanted_objects_from_memberfolder(portal,memberfolder,logger):
ct = getToolByName(portal,'portal_catalog')
strURL = "/".join(memberfolder.getPhysicalPath())
query = {'path':{'query':strURL},'portal_type':('Space','RecycleBin')}
objMemSpaces = [b.getObject() for b in ct(query)]
for o in objMemSpaces:
if callable(o.id):
o_id = o.id()
else:
o_id = o.id
try:
from plone.locking.interfaces import ILockable
lockable = ILockable(o)
was_locked = False
if lockable.locked():
was_locked = True
lockable.unlock()
parentItem = o.getParentNode()
parentItem.manage_delObjects(ids=[o_id])
transaction.savepoint()
except ComponentLookupError:
pass
logger.info("Deleted %s object from %s member folder." % (o_id, memberfolder.getId(),))
transaction.savepoint()
示例5: handleCancelCheckout
# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import locked [as 别名]
def handleCancelCheckout(event):
lockable = ILockable(event.object)
if lockable.locked():
# unlock working copy if it was auto-locked, or this will fail
lockable.clear_locks()
lock.unlockContext(event.baseline)
event.baseline.reindexObject(idxs=['review_state'])
示例6: test_locked_is_false_if_lock_is_invalid
# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import locked [as 别名]
def test_locked_is_false_if_lock_is_invalid(self):
create(Builder('lock')
.of_obj(self.wrapper)
.having(time=utcnow_tz_aware() - timedelta(seconds=800)))
lockable = ILockable(self.wrapper)
self.assertFalse(lockable.locked())
示例7: test_unlock_does_not_check_if_lock_is_stealable_when_stealable_only_is_false
# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import locked [as 别名]
def test_unlock_does_not_check_if_lock_is_stealable_when_stealable_only_is_false(self):
lockable = ILockable(self.wrapper)
lockable.lock()
# manually change lock creator
lock = Lock.query.first()
lock.creator = 'other-user'
lockable.unlock()
self.assertFalse(lockable.locked())
示例8: unlockPerson
# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import locked [as 别名]
def unlockPerson(self):
obj = self.context.aq_inner
try:
from plone.locking.interfaces import ILockable
HAS_LOCKING = True
except ImportError:
HAS_LOCKING = False
if HAS_LOCKING:
lockable = ILockable(obj)
if lockable.locked():
lockable.unlock()
return self.render()
示例9: test_force_unlock_clears_lock
# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import locked [as 别名]
def test_force_unlock_clears_lock(self, browser):
self.login(self.regular_user, browser)
with freeze(FREEZE_DATE):
oc_url = self.fetch_document_checkout_oc_url(browser, self.document)
expected_token = {
u'action': u'checkout',
u'documents': [u'createtreatydossiers000000000002'],
u'exp': 4121033100,
u'sub': u'kathi.barfuss',
u'url': u'http://nohost/plone/oc_checkout',
}
raw_token = oc_url.split(':')[-1]
token = jwt.decode(raw_token, JWT_SIGNING_SECRET_PLONE, algorithms=('HS256',))
self.assertEqual(expected_token, token)
lockable = ILockable(self.document)
self.lock_document(browser, raw_token, self.document)
self.assertTrue(lockable.locked())
self.login(self.manager, browser)
browser.open(self.document)
browser.click_on("Unlock")
self.assertFalse(lockable.locked())
示例10: move_all_items_totarget
# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import locked [as 别名]
def move_all_items_totarget(portal,sourcespace,targetspace,logger):
ct = getToolByName(portal,'portal_catalog')
logger.info("Moving items from %s to %s" % (sourcespace,targetspace,))
if sourcespace <> None:
#impersonate owner of the space
#print >> out, "impersonating owner of space: %s" % (sourcespace.Title(),)
#impersonateOwner(portal,sourcespace)
strPath = sourcespace.getPhysicalPath()
strURL = "/".join(strPath)
query = {'path': {'query': strURL},'portal_type':spacesdefaultaddablenonfolderishtypes}
objects = [b.getObject() for b in ct(query)]
logger.info("Moving %s items from space : %s" % (len(objects), sourcespace,))
for o in objects:
if callable(o.id):
o_id = o.id()
else:
o_id = o.id
try:
from plone.locking.interfaces import ILockable
lockable = ILockable(o)
was_locked = False
if lockable.locked():
was_locked = True
lockable.unlock()
parentobject = o.getParentNode()
cb = parentobject.manage_cutObjects(ids=[o_id])
targetspace.manage_pasteObjects(cb)
if was_locked:
lockable.lock()
transaction.savepoint()
except ComponentLookupError:
pass
#impersonateAdminUser(portal)
query1 = query = {'path': {'query': "/".join(targetspace.getPhysicalPath()),'depth':1},'portal_type':spacesdefaultaddablenonfolderishtypes}
movedobjects = ct(query1)
logger.info("Moved %s items to space : %s" % (len(movedobjects), targetspace,))
示例11: kss_obj_delete
# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import locked [as 别名]
def kss_obj_delete(self, selector='.kssDeletionRegion'):
obj = self.context.aq_inner
if obj.getPortalTypeName() == 'Discussion Item':
parent = obj.inReplyTo()
if parent is not None:
portal_discussion = getUtility(IDiscussionTool)
talkback = portal_discussion.getDiscussionFor(parent)
else:
talkback = obj.aq_parent
# remove the discussion item
talkback.deleteReply( str(obj.getId()) )
else:
# 被锁定时先解锁
if HAS_LOCKING:
lockable = ILockable(obj)
if lockable.locked():
lockable.unlock()
parent = obj.aq_parent
# archetypes的manage_delObjects会检查每个item的删除权限
originalSecurityManager = SecurityManagement.getSecurityManager()
SecurityManagement.newSecurityManager(None, User.SimpleUser('admin','',('Manager',), ''))
parent.manage_delObjects(str(obj.getId()))
SecurityManagement.setSecurityManager(originalSecurityManager)
if selector.startswith('redirect2'):
# 跳转到某个地址
# 需要定义 # class="kssattr-delSelector-redirect2http://test.everydo.com"
redirect2url = selector[len('redirect2'):]
self.getCommandSet('zopen').redirect(url=redirect2url)
else:
core = self.getCommandSet('core')
effects = self.getCommandSet('effects')
selector = core.getParentNodeSelector(selector)
# effects.effect(selector, 'fade')
core.deleteNode(selector)
self.getCommandSet('plone').issuePortalMessage(
translate(_(u'Deleted.'), default="Deleted.", context=self.request),
translate(_(u'Info'), default="Info", context=self.request))
return self.render()
示例12: move_project_advisory
# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import locked [as 别名]
def move_project_advisory(obj, event=None):
"""Move advisory to other theme if project changes its theme.
This event is called everytime an object with a theme is updated.
After the initial migration to the new theme folders, some projects
will need to be linked to a different theme. When an advisory is
linked to this project, the theme of the advisory must be updated as
well. This means we need to move the advisory to a different theme
folder.
"""
# Be defensive in case we are called on an object that is not a Project.
advisory_getter = getattr(obj, 'get_public_advisory', None)
if advisory_getter is None:
return
advisory = advisory_getter()
if advisory is None:
return
project_theme = obj.getThemeTitle()
advisory_theme = advisory.getThemeTitle()
if project_theme == advisory_theme:
return
target = obj.getThemeObject()
lockable = ILockable(advisory)
if lockable.locked():
# During migration, we always want to unlock. During daily use, we
# want to be a bit more careful.
if event is not None:
lock_info = lockable.lock_info()[0]
lock_age = time.time() - lock_info.get('time', 0)
if lock_age < (5 * 60):
IStatusMessage(obj.REQUEST).addStatusMessage(
u'Gelinkt advies kon niet verplaatst worden naar nieuw '
u'thema: het wordt nu bewerkt door %s.' %
lock_info.get('creator'),
type='warning')
return
lockable.unlock()
logger.info("Unlocked advisory %s", advisory.title)
logger.info("Moving advisory %s from %r to %r",
advisory.title, advisory_theme, project_theme)
api.content.move(source=advisory, target=target)
示例13: setId
# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import locked [as 别名]
def setId(self, value):
"""Sets the object id.
"""
if value != self.getId():
parent = aq_parent(aq_inner(self))
if parent is not None:
# See Referenceable, keep refs on what is a move/rename
self._v_cp_refs = 1
# We can't rename if the object is locked
if HAS_LOCKING:
lockable = ILockable(self)
was_locked = False
if lockable.locked():
was_locked = True
lockable.unlock()
parent.manage_renameObject(self.id, value)
if was_locked:
lockable.lock()
else:
parent.manage_renameObject(self.id, value)
self._setId(value)
示例14: _set_id
# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import locked [as 别名]
def _set_id(self, value):
if not value:
return
context = aq_inner(self.context)
parent = aq_parent(context)
if parent is None:
# Object hasn't been added to graph yet; just set directly
context.id = value
return
new_id = INameChooser(parent).chooseName(value, context)
if getattr(aq_base(context), 'id', None):
transaction.savepoint()
locked = False
lockable = ILockable(context, None)
if lockable is not None and lockable.locked():
locked = True
lockable.unlock()
parent.manage_renameObject(context.getId(), new_id)
if locked:
lockable.lock()
else:
context.id = new_id
示例15: setId
# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import locked [as 别名]
def setId(self, value):
# Sets the object id.
# avoid CopyError in OFS.CopySupport.manage_renameObject(),
# see http://dev.plone.org/ticket/8338
value = value.strip()
if value != self.getId():
parent = aq_parent(aq_inner(self))
if parent is not None:
# See Referenceable, keep refs on what is a move/rename
self._v_cp_refs = 1
# We can't rename if the object is locked
if HAS_LOCKING:
lockable = ILockable(self)
was_locked = False
if lockable.locked():
was_locked = True
lockable.unlock()
parent.manage_renameObject(self.id, value)
if was_locked:
lockable.lock()
else:
parent.manage_renameObject(self.id, value)
self._setId(value)