예제 #1
0
 def secure_render_recursive(item):
     try:
         return IHttpRestView(item).render_recursive(request, depth - 1)
     except Unauthorized:
         permissions = effective_perms(get_interaction(item), item)
         if 'view' in permissions:
             return dict(access='denied', permissions=permissions,
                         __type__=type(removeSecurityProxy(item)).__name__)
예제 #2
0
 def secure_render_recursive(item):
     try:
         return IHttpRestView(item).render_recursive(request, depth - 1)
     except Unauthorized:
         permissions = effective_perms(get_interaction(item), item)
         if 'view' in permissions:
             return dict(access='denied',
                         permissions=permissions,
                         __type__=type(
                             removeSecurityProxy(item)).__name__)
예제 #3
0
    def render_GET(self, request):
        if not request.interaction.checkPermission('view', self.context):
            raise NotFound

        data = model_to_dict(self.context)

        data['id'] = self.context.__name__
        data['__type__'] = type(removeSecurityProxy(self.context)).__name__
        try:
            data['url'] = ILocation(self.context).get_url()
        except Unauthorized:
            data['url'] = ''

        interaction = get_interaction(self.context)
        data['permissions'] = effective_perms(interaction, self.context) if interaction else []

        # XXX: simplejson can't serialize sets
        if 'tags' in data:
            data['tags'] = list(data['tags'])

        return data
예제 #4
0
    def render_GET(self, request):
        if not request.interaction.checkPermission('view', self.context):
            raise NotFound

        data = model_to_dict(self.context)

        data['id'] = self.context.__name__
        data['__type__'] = type(removeSecurityProxy(self.context)).__name__
        try:
            data['url'] = ILocation(self.context).get_url()
        except Unauthorized:
            data['url'] = ''

        interaction = get_interaction(self.context)
        data['permissions'] = effective_perms(
            interaction, self.context) if interaction else []

        # XXX: simplejson can't serialize sets
        if 'tags' in data:
            data['tags'] = list(data['tags'])

        return data