• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python security.checkPermission函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中zope.security.checkPermission函数的典型用法代码示例。如果您正苦于以下问题:Python checkPermission函数的具体用法?Python checkPermission怎么用?Python checkPermission使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: isAvailable

    def isAvailable(self):
        context = self.context
        if checkPermission('zojax.AddPhoto', context) or \
                checkPermission('zojax.SubmitPhoto', context):
            return True

        return False
开发者ID:Zojax,项目名称:zojax.photoalbum,代码行数:7,代码来源:actions.py


示例2: create_sittings_map

def create_sittings_map(sittings, request):
    """Returns a dictionary that maps:

      (day, hour) -> {
         'record'   : sitting database record
         'actions'  : actions that apply to this sitting
         'class'    : sitting
         'span'     : span
         }
         
      (day, hour) -> ``None``
      
    If the mapped value is a sitting, then a sitting begins on that
    day and hour, if it's ``None``, then a sitting is reaching into
    this day and hour.
    
    The utility of the returned structure is to aid rendering a
    template with columns spanning several rows.
    """

    mapping = {}
    for sitting in sittings.values():
        day = sitting.start_date.weekday()
        hour = sitting.start_date.hour

        start_date = utils.timedict(sitting.start_date.hour, sitting.start_date.minute)

        end_date = utils.timedict(sitting.end_date.hour, sitting.end_date.minute)

        status = misc.get_wf_state(sitting)

        proxied = ProxyFactory(sitting)

        if checkPermission(u"bungeni.agendaitem.wf.schedule", proxied):
            link = "%s/schedule" % url.absoluteURL(sitting, request)
        else:
            link = url.absoluteURL(sitting, request)

        if checkPermission("zope.View", proxied):
            mapping[day, hour] = {
                "url": link,
                "record": sitting,
                "class": u"sitting",
                "actions": get_sitting_actions(sitting, request),
                "span": sitting.end_date.hour - sitting.start_date.hour,
                "formatted_start_time": start_date,
                "formatted_end_time": end_date,
                "status": status,
            }
            for hour in range(sitting.start_date.hour + 1, sitting.end_date.hour):
                mapping[day, hour] = None

        # make sure start- and end-date is the same DAY
        assert (
            (sitting.start_date.day == sitting.end_date.day)
            and (sitting.start_date.month == sitting.end_date.month)
            and (sitting.start_date.year == sitting.end_date.year)
        )

    return mapping
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:60,代码来源:browser.py


示例3: __call__

 def __call__(self):
     if checkPermission('simplemanagement.EditCompass', self.context):
         return super(Compass, self).__call__()
     elif checkPermission('simplemanagement.ViewCompass', self.context):
         self.request.response.redirect('{0}history'.format(self.base_url()))
         return u''
     raise Unauthorized
开发者ID:caiuka,项目名称:collective.simplemanagement,代码行数:7,代码来源:compass.py


示例4: update

    def update(self):
        if self.updated:
            return

        self.updated = True

        context = self.context
        if checkPermission('zojax.ModifyTaskStatus', context):
            self.severity = getUtility(
                IVocabularyFactory, 'project.task.severity')(context)

        if checkPermission('zojax.ModifyTaskAttributes', context):
            self.allowAttributes = True

        if checkPermission('zojax.AssignTo', context):
            self.allowAssign = True

        if checkPermission('zojax.AddContentAttachment', context):
            self.allowAttachments = True

        self.wfinfo = IWorkflowInfo(context)
        self.wfinfo.fireAutomatic()

        # subscribers
        auth = getUtility(IAuthentication)

        subs = getSubscribers(('tasks',), context)
        assignees = getSubscribers(('assigneetasks'), context)

        for pid in IAssignments(context).assignees:
            if pid in assignees:
                subs.add(pid)

        subscribers = []
        for subs in subs:
            try:
                principal = auth.getPrincipal(subs)
            except PrincipalLookupError:
                continue

            profile = IPersonalProfile(principal)

            subscribers.append(profile.title)

        subscribers.sort()
        self.subscribers = subscribers

        task = removeAllProxies(context)
        if checkPermission('zojax.ModifyContent', task.__parent__.__parent__):
            self.manageSubscribers = absoluteURL(
                task.__parent__.__parent__, self.request)

        super(TaskCommentForm, self).update()

        include('jquery-plugins')

        if 'file' in self.widgets:
            self.widgets['file'].klass = 'multi'
开发者ID:Zojax,项目名称:zojax.project,代码行数:58,代码来源:taskcomment.py


示例5: update

    def update(self):
        context = self.context
        request = self.request

        self.noIcon = not bool(self.context.icon)

        principal = self.request.principal
        if not IUnauthenticatedPrincipal.providedBy(principal):
            self.menu = True

            self.submitTopic = \
                checkPermission('zojax.forum.AddTopic', context) or \
                checkPermission('zojax.forum.SubmitTopic', context)

            notifications = getAdapter(context, IContentNotification, 'forum')
            self.subscribed = notifications.isSubscribed(principal.id)

        if len(self.context) > 1:
            self.searching = True

        data = ISession(request)[SESSIONKEY]
        forum = removeAllProxies(context)
        key = getUtility(IIntIds).getId(forum)

        if 'form.button.search' in request:
            searchableText = request['form.searchforum']
            data[key] = (searchableText, True)

        if 'form.button.clear' in request:
            searchableText = None
            if key in data:
                del data[key]

        else:
            searchtext, searching = data.get(key, (u'', False))
            if searchtext and searching:
                searchableText = searchtext
            else:
                searchableText = None

        if searchableText:
            query = {'searchableText': searchableText,
                     'type': {'any_of': ('forum.message',)},
                     'traversablePath': {'any_of': (forum,)},
                     'noPublishing': True, 'noSecurityChecks': True}

            try:
                results = getUtility(ICatalog).searchResults(**query)
            except Exception, e:
                IStatusMessage(self.request).add(e, 'error')
                return

            self.total = len(results)
            self.searchableText = searchableText
            self.searchResults = Batch(results, size=20, request=request)
开发者ID:Zojax,项目名称:zojax.forum,代码行数:55,代码来源:forumview.py


示例6: __call__

    def __call__(self):
        try:
            date = self.request.get("from")
            dateobj = datetime.datetime(*time.strptime(date, "%Y-%m-%d")[0:5])
            start_date = utils.datetimedict.fromdate(dateobj)
        except:
            start_date = None

        try:
            date = self.request.get("to")
            dateobj = datetime.datetime(*time.strptime(date, "%Y-%m-%d")[0:5])
            end_date = utils.datetimedict.fromdate(dateobj)
        except:
            end_date = None

        if start_date is None:
            start_date = utils.datetimedict.fromdate(datetime.date.today())
            days = tuple(start_date + timedelta(days=d) for d in range(7))
            end_date = days[-1]
        elif end_date is None:
            start_date = utils.datetimedict.fromdate(datetime.date.today())
            days = tuple(start_date + timedelta(days=d) for d in range(7))
            end_date = days[-1]
        sittings = self.context.get_sittings(start_date, end_date)
        self.sittings = []
        for sitting in sittings.values():
            if checkPermission("zope.View", sitting):
                trusted = removeSecurityProxy(sitting)
                trusted.text = dict(sitting_status=_(misc.get_wf_state(trusted, trusted.status)))
                self.sittings.append(trusted)
        self.request.response.setHeader("Content-type", self.content_mimetype)
        return self.render()
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:32,代码来源:browser.py


示例7: render

 def render(self, template=None):
     if template is None:
         template = self.template
     if (not checkPermission(u"bungeni.sitting.Add", self.context)) or \
         (IBusinessSectionLayer.providedBy(self.request)):
         self.edit = False
     else:
         self.edit = True
     session = Session()
     venues = session.query(domain.Venue).all()
     languages = get_all_languages()
     session.close()
     self.display_language = get_default_language()
     if self.request.get("I18N_LANGUAGE"):
         self.display_language = self.request.get("I18N_LANGUAGE")
     #html is hardcoded in here because doing it in the template
     #would have been a colossal pain
     #TODO: FIX THIS
     s = '<div class="dhx_cal_ltext" style="height:90px;">' 
     s += '<table>'
     s += '<tr><td>Venue</td><td><select id="select_sitting_venue">'
     for venue in venues:
         s += '<option value="'+str(venue.venue_id)+'">'+venue.short_name+'</option>'
     s += '</select></td></tr>'
     s += '<tr><td>Language</td><td><select id="select_sitting_lang">'
     for lang in languages:
         if lang == 'en':
             s += '<option value="'+lang+'" selected>'+lang+'</option>'
         else:
             s += '<option value="'+lang+'">'+lang+'</option>'
     s += '</select></td></tr></table></div>'
     self.sitting_details_form = s
     return template()
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:33,代码来源:browser.py


示例8: listDrafts

    def listDrafts(self):
        ids = getUtility(IIntIds)
        request = self.request
        context = self.context

        drafts = []
        for name in context:
            draft = context[name]
            if not checkPermission('zope.View', draft):
                continue

            try:
                loc = ids.queryObject(draft.location)
                locTitle = loc.title
                locUrl = '%s/'%absoluteURL(loc, request)
            except:
                locTitle = _('Unknown')
                locUrl = u''

            dc = ICMFDublinCore(draft.content)

            info = {'name': name,
                    'title': draft.title or _('[No title]'),
                    'description': draft.description,
                    'url': '%s/'%absoluteURL(draft, request),
                    'location': locTitle,
                    'locationURL': locUrl,
                    'icon': queryMultiAdapter((draft, request), name='zmi_icon'),
                    'draft': draft,
                    'modified': dc.modified,
                    'status': ISubmittedDraftContent.providedBy(draft),
                    'contentType': IContentType(draft.content)}
            drafts.append(info)

        return drafts
开发者ID:Zojax,项目名称:zojax.content.draft,代码行数:35,代码来源:draftcontainer.py


示例9: update

    def update(self):
        super(MemberMessageNotification, self).update()

        context = self.context
        request = self.request

        group = removeAllProxies(context.context).__parent__
        visible = checkPermission('zope.View', group)

        owner = IOwnership(group).owner
        profile = IPersonalProfile(owner, None)

        message = cgi.escape(context.message)
        message = message.replace(' ', '&nbsp;')
        message = message.replace('\n', '<br />')

        self.title = group.title
        self.sender = getattr(profile, 'title', 'Unknown member')

        self.info = {
            'title': group.title,
            'description': group.description,
            'created': IDCTimes(group).created,
            'members': len(group),
            'url': '%s/'%absoluteURL(group, request),
            'message': message,
            'default': not visible or not bool(getattr(group, 'logo', None)),
            'sender': self.sender}

        if profile is not None:
            self.addHeader(u'From', formataddr((self.sender, profile.email),))

        self.site = getSite()
        self.siteTitle = getattr(self.site, 'title', u'') or self.site.__name__
        self.siteURL = u'%s'%absoluteURL(self.site, request)
开发者ID:Zojax,项目名称:zojax.members,代码行数:35,代码来源:messagetemplate.py


示例10: get_sessions

 def get_sessions(self):
     sessions = [ removeSecurityProxy(session) for key, session in 
         self.context.get_group().sessions.items()
         if checkPermission("bungeni.session.View", session)
     ]
     sessions.sort(key=lambda sess:sess.start_date)
     return sessions
开发者ID:gelie,项目名称:bungeni_src,代码行数:7,代码来源:browser.py


示例11: getMenuItems

 def getMenuItems(self, context, request):
     """Return menu item entries in a TAL-friendly form."""
     _url = url.absoluteURL(context, request)
     if checkPermission("bungeni.translation.Add", context):
         language = get_language(context)
         available = get_available_translations(context)
         results = []
         for name, obj in get_all_languages().items():
             title = obj["name"]
             # skip the current language
             if name == language:
                 continue
             action_url = "%s/translate?language=%s" % (_url, name)
             extra = {
                 "id": "translation-action-%s" % name,
                 "separator": None,
                 "class": ""
             }
             translation_id = available.get(name)
             results.append(
                 dict(title=title,
                      description="",
                      action=action_url,
                      selected=translation_id is not None,
                      icon=None,
                      extra=extra,
                      submenu=None))
         return results
     else:
         return None
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:30,代码来源:menu.py


示例12: list_container_items

def list_container_items(container, permission="zope.View"):
    """Generate list of container items with permission check
    """
    trusted = proxy.removeSecurityProxy(container)
    for contained in trusted.values():
        if checkPermission(permission, contained):
            yield contained
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:7,代码来源:common.py


示例13: __call__

 def __call__(self, force=None):
     """ try executing all pending request with dates older than "now" """
     if not checkPermission('synchro.Execute', self.context):
         raise Forbidden
     if self.storage.busy:
         if force:
             LOG_INFO("Forcing synchro on busy storage")
         else:
             LOG_ERROR("Synchro is busy, use force=true to force execution")
             raise BadRequest("Synchro is busy")
     LOG_INFO("Locking synchro", BLATHER)
     self.storage.busy = True
     transaction.commit()
     LOG_INFO("Starting synchro processing", BLATHER)
     processed = 0
     try:
         for entry in self.olderPending():
             self.process(entry)
             processed += 1
         return "Synchro finished. %s entries processed" % processed
     finally:
         LOG_INFO("Unlocking synchro", BLATHER)
         self.storage.busy = False
         transaction.commit()
         LOG_INFO("Synchro finished. %s entries processed" % processed, BLATHER)
开发者ID:stxnext,项目名称:stxnext.scheduler,代码行数:25,代码来源:synchro.py


示例14: execute_static_deployment

 def execute_static_deployment(self, entry):
     """
     executes defined staticdeployment process
     @rtype: dict
     """
     response = {}
     action = entry.action
     
     def handle_error(msg):
         LOG_ERROR(msg)
         response['status'] = 'error'
         response['data'] = [msg]
         
     if not checkPermission('static.Export', self.context):
         mtool = getToolByName(self.context, 'portal_membership')
         username = mtool.getMemberInfo().get('username', '')
         errmsg = "User '%s' has no 'static.Export' permission" % username
         handle_error(errmsg)
         return response
     
     action_items = getattr(entry, 'props', {})
     staticdeployment = getMultiAdapter((self.context, self.request),
                                         name='staticdeployment-controlpanel')
     if not action_items.has_key('section_choice'):
         errmsg = "Deployment skin is not defined in config file"
         handle_error(errmsg)
         return response
     
     staticdeployment._on_save(dict(action_items))
     response['status'] = 'ok'
           
     return response
开发者ID:stxnext,项目名称:stxnext.scheduler,代码行数:32,代码来源:synchro.py


示例15: getMenuItems

    def getMenuItems(self, context, request):
        """Return menu item entries in a TAL-friendly form."""

        types = []
        for type_ in getAllUtilitiesRegisteredFor(ITileType):
            if checkPermission(type_.add_permission, context):
                try:
                    if request.traverseName(
                        context, "@@" + type_.__name__):
                        types.append(type_)
                except NotFound:
                    continue
        types.sort(lambda x, y: cmp(x.title, y.title))

        normalizer = getUtility(IIDNormalizer)
        return [{
                'title': type_.title,
                'description': type_.description,
                'action': "%s/@@add-tile?form.button.Create=1&type=%s"\
                    % (context.absolute_url(), type_.__name__),
                'selected': False,
                'icon': None,
                'extra': {
                    'id': "add-%s" % normalizer.normalize(type_.__name__),
                    'separator': None, 'class': ''
                    },
                'submenu': None,
                } for type_ in types]
开发者ID:datakurre,项目名称:jyu.portfolio.layout,代码行数:28,代码来源:behaviors.py


示例16: showCreateCommunity

 def showCreateCommunity(self):
     """ The Contributor role is assumed that will be applied at the group in
         the portal root.
     """
     if IHomePage.providedBy(self.context) and \
        checkPermission('ulearn.addCommunity', self.portal()):
         return True
开发者ID:UPCnet,项目名称:ulearn.theme,代码行数:7,代码来源:communities.py


示例17: values

 def values(self):
     workflow = get_workflow(self.context.domain_model.__name__.lower())
     public_wfstates = workflow.get_state_ids(tagged=["public"],
         restrict=False)
     return [ x for x in self.context.values()
         if checkPermission("zope.View", x)
              and x.status in public_wfstates ]
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:7,代码来源:adaptors.py


示例18: tileTypes

    def tileTypes(self):
        """Get a list of addable ITileType objects representing tiles
        which are addable in the current context
        """
        tiles = []

        for tile_name in getUtility(IRegistry)['plone.app.tiles']:
            tiletype = getUtility(ITileType, tile_name)
            # check if we have permission to add this tile
            if checkPermission(tiletype.add_permission, self.context):
                # tile actions
                # TODO: read from registry
                tiletype.actions = [{
                    'name': 'edit',
                    'url': '@@edit-tile',
                    'title': _('Edit'),
                }, {
                    'name': 'remove',
                    'url': '@@delete-tile',
                    'title': _('Remove'),
                }]
                tiles.append(tiletype)

        tiles.sort(self.tileSortKey)
        return tiles
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:25,代码来源:traversal.py


示例19: show_controls

    def show_controls(self):
        """ Returns True if the sources should be modifyable/removeable. """

        # not exactly the required permission, but that's not the point:
        # if the user has the permission to edit the context the permission
        # to edit the sources probably inherited.
        return checkPermission('cmf.ModifyPortalContent', self.context)
开发者ID:seantis,项目名称:seantis.placemap,代码行数:7,代码来源:map.py


示例20: update

    def update(self):
        try:
            author = getUtility(IAuthentication).getPrincipal(
                self.context.author)
        except:
            author = None

        if author is not None:
            profile = IPersonalProfile(author)
            self.avatar = profile.avatarUrl(self.request)
            self.author = profile.title

            if profile.space is not None:
                self.url = absoluteURL(profile.space, self.request)
        else:
            self.avatar = u'%s/@@profile.avatar/0'%absoluteURL(
                getSite(), self.request)

        if author is not None or author == u'Unauthenticated User':
            if getattr(self.context, 'authorName'):
                self.author = self.context.authorName
                if 'social_avatar_url' in dir(self.context) and self.context.social_type:
                    self.social_avatar = self.context.social_avatar_url
                    if self.context.social_type==1:
                        self.social_name = 'Twitter'
                    elif self.context.social_type==2:
                        self.social_name = 'Facebook'

        self.comment = self.context.comment

        content = self.context.content
        self.postsAllowed = (
            IContentDiscussion(content).status in [1, 4] and
            checkPermission('zojax.AddComment', content))
开发者ID:Zojax,项目名称:zojax.content.discussion,代码行数:34,代码来源:comment.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python checker.defineChecker函数代码示例发布时间:2022-05-26
下一篇:
Python vocabulary.SimpleVocabulary类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap