コード例 #1
0
    def __call__(self, *args, **kwargs):
        if not checkPermission(self._permission, self.context):
            raise Unauthorized()

        portal_url = getToolByName(self.context, 'portal_url')

        zpt = ZopePageTemplate(self.__name__, text=self._template)
        boundNames = {
            'context': self.context,
            'request': self.request,
            'view': self,
            'portal_url': portal_url(),
            'portal': portal_url.getPortalObject(),
        }
        if self._owner is not None:
            zpt.changeOwnership(self._owner)
        zpt = zpt.__of__(self.context)
        try:
            return zpt._exec(boundNames, args, kwargs)
        except NotFound, e:
            # We don't want 404's for these - they are programming errors
            raise Exception(e)
コード例 #2
0
    def __call__(self, *args, **kwargs):
        if not checkPermission(self._permission, self.context):
            raise Unauthorized()

        portal_url = getToolByName(self.context, 'portal_url')

        zpt = ZopePageTemplate(self.__name__, text=self._template)
        boundNames = {
            'context': self.context,
            'request': self.request,
            'view': self,
            'portal_url': portal_url(),
            'portal': portal_url.getPortalObject(),
        }
        if self._owner is not None:
            zpt.changeOwnership(self._owner)
        zpt = zpt.__of__(self.context)
        try:
            return zpt._exec(boundNames, args, kwargs)
        except NotFound, e:
            # We don't want 404's for these - they are programming errors
            raise Exception(e)