Пример #1
0
    def __call__(self):
        """Called on view being published
        """
        context = aq_inner(self.context)
        request = aq_inner(self.request)
        session = request.get("SESSION", {})

        pleaseDontCache(context, request)

        # Updating attributes from request values
        for name in (
            "rootpath",
            "browse",
            "showbreadcrumbs",
            "multiselect",
            "forcecloseoninsert",
            "types",
            "typeupload",
            "typefolder",
            "typeview",
            "displaywithoutquery",
            "query",
            "imagestypes",
            "filestypes",
            "selectiontype",
            "allowimagesizeselection",
            "fieldid",
            "fieldname",
            "fieldtype",
            "ispopup",
            "showblacklisted",
            "searchsubmit",
            "allowupload",
            "allowaddfolder",
        ):
            setattr(self, name, request.get(name, getattr(self, name)))

        if not self.browse:
            self.showbreadcrumbs = False

        self.setScopeInfos(context, request, self.showbreadcrumbs)

        if not self.multiselect:
            self.forcecloseoninsert = 1

        if self.typeview == "image":
            self.typecss = "float"

        if request.get("finder_sort_on"):
            self.sort_on = request.get("finder_sort_on")
            self.sort_order = request.get("sort_order", self.sort_order)

            # sort_order could be empty or reverse, or ascending
            if self.sort_order == "reverse":
                self.sort_inverse = "ascending"
            elif self.sort_order == "ascending":
                self.sort_inverse = "reverse"
            self.sort_request = True
            if self.sort_on not in self.data["catalog"].indexes():
                self.sort_withcatalog = False

        # Use self.blacklist (or blacklist in session or request) to remove some
        # uids from results
        rblacklist = request.get("blacklist", self.blacklist)
        sblacklist = session.get("blacklist", rblacklist)
        if sblacklist and not rblacklist and not request.get("newsession", False):
            self.blacklist = sblacklist
        else:
            self.blacklist = rblacklist

        # Use self.addtoblacklist (or addtoblacklist in request) to add elements
        # in blacklist
        addtoblacklist = request.get("addtoblacklist", self.addtoblacklist)
        for k in addtoblacklist:
            if k not in self.blacklist:
                self.blacklist.append(k)

        # Use self.removefromblacklist (or removefromblacklist in request) to
        # remove elements from blacklist
        removefromblacklist = request.get("removefromblacklist", self.removefromblacklist)
        for k in removefromblacklist:
            if k in self.blacklist:
                self.blacklist.remove(k)

        # Put new blacklist in session
        # FIXME: KISS
        if session:
            if request.get("emptyblacklist", False):
                session.set("blacklist", [])
            else:
                session.set("blacklist", self.blacklist)

        firstpassresults = self.finderResults()
        if self.sort_request and not self.sort_withcatalog:
            firstpassresults.sort(key=lambda k: k[self.sort_on])
            if self.sort_order == "reverse":
                firstpassresults.reverse()

        # remove blacklisted uids or just set it as blacklisted if needed
        results = []

        if self.selectiontype == "uid":
            for r in firstpassresults:
                if r["uid"] not in self.blacklist or self.typeview == "selection":
                    results.append(r)
                elif self.showblacklisted:
                    r["blacklisted"] = True
                    results.append(r)

        self.results = results
        self.folders = []
        self.rootfolders = []
        if self.browse:
            self.folders = self.finderBrowsingResults()
            if self.data["scope"] is self.data["root"]:
                self.rootfolders = self.folders
            else:
                self.rootfolders = self.finderNavBrowsingResults()

        self.cleanrequest = self.cleanRequest()

        # Upload disallowed if user do not have permission to Add portal content
        # on main window context
        if self.allowupload:
            tool = getToolByName(context, "portal_membership")
            if not (tool.checkPermission("Add portal content", self.data["scope"])):
                self.allowupload = False
            if not IFinderUploadCapable.providedBy(self.data["scope"]):
                self.allowupload = False

        # Allowaddfolder disallowed if user do not have permission to add portal
        # content on context disallowed also when context is not
        # IFinderUploadCapable
        # FIXME: This should require allowupload otherwise this has no sense
        if self.allowaddfolder:
            tool = getToolByName(context, "portal_membership")
            if not (tool.checkPermission("Add portal content", self.data["scope"])):
                self.allowaddfolder = False
            if not IFinderUploadCapable.providedBy(self.data["scope"]):
                self.allowaddfolder = False

        self.cleanrequest = self.cleanRequest()

        return self.template()
 def __call__(self):
     """Publishing the view through browser
     """
     pleaseDontCache(self.context, self.request)
     # Render
     return self.template()
Пример #3
0
    def __call__(self):
        """Called on view being published
        """
        context = aq_inner(self.context)
        request = aq_inner(self.request)
        session = request.get('SESSION', {})

        pleaseDontCache(context, request)

        # Updating attributes from request values
        for name in (
            'rootpath', 'browse', 'showbreadcrumbs', 'multiselect',
            'forcecloseoninsert', 'types', 'typeupload', 'typefolder',
            'typeview', 'displaywithoutquery', 'query', 'imagestypes',
            'filestypes', 'selectiontype', 'allowimagesizeselection', 'fieldid',
            'fieldname', 'fieldtype', 'ispopup', 'showblacklisted',
            'searchsubmit', 'allowupload', 'allowaddfolder'
            ):
            setattr(self, name, request.get(name, getattr(self, name)))

        if not self.browse:
            self.showbreadcrumbs = False

        self.setScopeInfos(context, request, self.showbreadcrumbs)

        if not self.multiselect:
             self.forcecloseoninsert = 1

        if self.typeview == 'image':
            self.typecss = 'float'

        if request.get('finder_sort_on'):
            self.sort_on = request.get('finder_sort_on')
            self.sort_order = request.get('sort_order', self.sort_order)

            # sort_order could be empty or reverse, or ascending
            if self.sort_order=='reverse':
                self.sort_inverse = 'ascending'
            elif self.sort_order=='ascending':
                self.sort_inverse = 'reverse'
            self.sort_request = True
            if self.sort_on not in self.data['catalog'].indexes():
                self.sort_withcatalog = False

        # Use self.blacklist (or blacklist in session or request) to remove some
        # uids from results
        rblacklist = request.get('blacklist', self.blacklist)
        sblacklist = session.get('blacklist', rblacklist)
        if sblacklist and not rblacklist and not request.get('newsession', False):
            self.blacklist = sblacklist
        else:
            self.blacklist = rblacklist

        # Use self.addtoblacklist (or addtoblacklist in request) to add elements
        # in blacklist
        addtoblacklist = request.get('addtoblacklist', self.addtoblacklist)
        for k in addtoblacklist:
            if k not in self.blacklist:
                self.blacklist.append(k)

        # Use self.removefromblacklist (or removefromblacklist in request) to
        # remove elements from blacklist
        removefromblacklist = request.get('removefromblacklist', self.removefromblacklist)
        for k in removefromblacklist:
            if k in self.blacklist:
                self.blacklist.remove(k)

        # Put new blacklist in session
        # FIXME: KISS
        if session:
            if request.get('emptyblacklist', False):
                session.set('blacklist', [])
            else:
                session.set('blacklist', self.blacklist)

        firstpassresults = self.finderResults()
        if self.sort_request and not self.sort_withcatalog:
            firstpassresults.sort(key=lambda k: k[self.sort_on])
            if self.sort_order == 'reverse':
                firstpassresults.reverse()

        # remove blacklisted uids or just set it as blacklisted if needed
        results = []

        if self.selectiontype == 'uid':
            for r in firstpassresults:
                if r['uid'] not in self.blacklist or self.typeview=='selection':
                    results.append(r)
                elif self.showblacklisted:
                    r['blacklisted'] = True
                    results.append(r)

        self.results = results
        self.folders = []
        self.rootfolders = []
        if self.browse:
            self.folders = self.finderBrowsingResults()
            if self.data['scope'] is self.data['root']:
                self.rootfolders = self.folders
            else:
                self.rootfolders = self.finderNavBrowsingResults()

        self.cleanrequest = self.cleanRequest()

        # Upload disallowed if user do not have permission to Add portal content
        # on main window context
        if self.allowupload:
            tool = getToolByName(context, "portal_membership")
            if not(tool.checkPermission('Add portal content', self.data['scope'])):
                self.allowupload = False
            if not IFinderUploadCapable.providedBy(self.data['scope']):
                self.allowupload = False

        # Allowaddfolder disallowed if user do not have permission to add portal
        # content on context disallowed also when context is not
        # IFinderUploadCapable
        # FIXME: This should require allowupload otherwise this has no sense
        if self.allowaddfolder:
            tool = getToolByName(context, "portal_membership")
            if not(tool.checkPermission('Add portal content', self.data['scope'])):
                self.allowaddfolder = False
            if not IFinderUploadCapable.providedBy(self.data['scope']):
                self.allowaddfolder = False

        self.cleanrequest = self.cleanRequest()

        return self.template()
 def __call__(self):
     """Publishing the view through browser
     """
     pleaseDontCache(self.context, self.request)
     # Render
     return self.template()
Пример #5
0
    def __call__(self):
        """Called on view being published
        """
        context = aq_inner(self.context)
        request = aq_inner(self.request)
        session = request.get('SESSION', {})

        pleaseDontCache(context, request)

        # Updating attributes from request values
        for name in ('rootpath', 'browse', 'showbreadcrumbs', 'multiselect',
                     'forcecloseoninsert', 'types', 'typeupload', 'typefolder',
                     'typeview', 'displaywithoutquery', 'query', 'imagestypes',
                     'filestypes', 'selectiontype', 'allowimagesizeselection',
                     'fieldid', 'fieldname', 'fieldtype', 'ispopup',
                     'showblacklisted', 'searchsubmit', 'allowupload',
                     'allowaddfolder'):
            setattr(self, name, request.get(name, getattr(self, name)))

        if not self.browse:
            self.showbreadcrumbs = False

        self.setScopeInfos(context, request, self.showbreadcrumbs)

        if not self.multiselect:
            self.forcecloseoninsert = 1

        if self.typeview == 'image':
            self.typecss = 'float'

        if request.get('finder_sort_on'):
            self.sort_on = request.get('finder_sort_on')
            self.sort_order = request.get('sort_order', self.sort_order)

            # sort_order could be empty or reverse, or ascending
            if self.sort_order == 'reverse':
                self.sort_inverse = 'ascending'
            elif self.sort_order == 'ascending':
                self.sort_inverse = 'reverse'
            self.sort_request = True
            if self.sort_on not in self.data['catalog'].indexes():
                self.sort_withcatalog = False

        # Use self.blacklist (or blacklist in session or request) to remove some
        # uids from results
        rblacklist = request.get('blacklist', self.blacklist)
        sblacklist = session.get('blacklist', rblacklist)
        if sblacklist and not rblacklist and not request.get(
                'newsession', False):
            self.blacklist = sblacklist
        else:
            self.blacklist = rblacklist

        # Use self.addtoblacklist (or addtoblacklist in request) to add elements
        # in blacklist
        addtoblacklist = request.get('addtoblacklist', self.addtoblacklist)
        for k in addtoblacklist:
            if k not in self.blacklist:
                self.blacklist.append(k)

        # Use self.removefromblacklist (or removefromblacklist in request) to
        # remove elements from blacklist
        removefromblacklist = request.get('removefromblacklist',
                                          self.removefromblacklist)
        for k in removefromblacklist:
            if k in self.blacklist:
                self.blacklist.remove(k)

        # Put new blacklist in session
        # FIXME: KISS
        if session:
            if request.get('emptyblacklist', False):
                session.set('blacklist', [])
            else:
                session.set('blacklist', self.blacklist)

        firstpassresults = self.finderResults()
        if self.sort_request and not self.sort_withcatalog:
            firstpassresults.sort(key=lambda k: k[self.sort_on])
            if self.sort_order == 'reverse':
                firstpassresults.reverse()

        # remove blacklisted uids or just set it as blacklisted if needed
        results = []

        if self.selectiontype == 'uid':
            for r in firstpassresults:
                if r['uid'] not in self.blacklist or self.typeview == 'selection':
                    results.append(r)
                elif self.showblacklisted:
                    r['blacklisted'] = True
                    results.append(r)

        self.results = results
        self.folders = []
        self.rootfolders = []
        if self.browse:
            self.folders = self.finderBrowsingResults()
            if self.data['scope'] is self.data['root']:
                self.rootfolders = self.folders
            else:
                self.rootfolders = self.finderNavBrowsingResults()

        self.cleanrequest = self.cleanRequest()

        # Upload disallowed if user do not have permission to Add portal content
        # on main window context
        if self.allowupload:
            tool = getToolByName(context, "portal_membership")
            if not (tool.checkPermission('Add portal content',
                                         self.data['scope'])):
                self.allowupload = False
            if not IFinderUploadCapable.providedBy(self.data['scope']):
                self.allowupload = False

        # Allowaddfolder disallowed if user do not have permission to add portal
        # content on context disallowed also when context is not
        # IFinderUploadCapable
        # FIXME: This should require allowupload otherwise this has no sense
        if self.allowaddfolder:
            tool = getToolByName(context, "portal_membership")
            if not (tool.checkPermission('Add portal content',
                                         self.data['scope'])):
                self.allowaddfolder = False
            if not IFinderUploadCapable.providedBy(self.data['scope']):
                self.allowaddfolder = False

        self.cleanrequest = self.cleanRequest()

        return self.template()