当前位置: 首页>>代码示例>>Python>>正文


Python ILockable.lock_info方法代码示例

本文整理汇总了Python中plone.locking.interfaces.ILockable.lock_info方法的典型用法代码示例。如果您正苦于以下问题:Python ILockable.lock_info方法的具体用法?Python ILockable.lock_info怎么用?Python ILockable.lock_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plone.locking.interfaces.ILockable的用法示例。


在下文中一共展示了ILockable.lock_info方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: lock_info

# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import lock_info [as 别名]
    def lock_info(self):
        """Get information about the current lock, a dict containing:

        creator - the id of the user who created the lock
        fullname - the full name of the lock creator
        author_page - a link to the home page of the author
        time - the creation time of the lock
        time_difference - a string representing the time since the lock was
        acquired.
        """

        portal_membership = getToolByName(self.context, 'portal_membership')
        portal_url = getToolByName(self.context, 'portal_url')
        lockable = ILockable(aq_inner(self.context))
        url = portal_url()
        for info in lockable.lock_info():
            creator = info['creator']
            time = info['time']
            token = info['token']
            lock_type = info['type']
            # Get the fullname, but remember that the creator may not
            # be a member, but only Authenticated or even anonymous.
            # Same for the author_page
            fullname = ''
            author_page = ''
            member = portal_membership.getMemberById(creator)
            if member:
                fullname = member.getProperty('fullname', '')
                author_page = "%s/author/%s" % (url, creator)
            if fullname == '':
                fullname = creator or _('label_an_anonymous_user',
                                        u'an anonymous user')
            time_difference = self._getNiceTimeDifference(time)

            return {
                'creator': creator,
                'fullname': fullname,
                'author_page': author_page,
                'time': time,
                'time_difference': time_difference,
                'token': token,
                'type': lock_type,
            }
开发者ID:Vinsurya,项目名称:Plone,代码行数:45,代码来源:locking.py

示例2: move_project_advisory

# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import lock_info [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)
开发者ID:milieuinfo,项目名称:minaraad,代码行数:44,代码来源:events.py

示例3: get_lock_creator_user_name

# 需要导入模块: from plone.locking.interfaces import ILockable [as 别名]
# 或者: from plone.locking.interfaces.ILockable import lock_info [as 别名]
 def get_lock_creator_user_name(self):
     lockable = ILockable(self.context)
     creator = lockable.lock_info()[0]['creator']
     return Actor.lookup(creator).get_label()
开发者ID:4teamwork,项目名称:opengever.core,代码行数:6,代码来源:edit_meeting.py


注:本文中的plone.locking.interfaces.ILockable.lock_info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。