示例#1
0
        def manage_FTPlist(self, REQUEST):
            """Directory listing for FTP.

            In the case of non-Foldoid objects, the listing should contain one
            object, the object itself.
            """
            from App.Common import is_acquired
            warn(
                u'manage_FTPlist is deprecated and will be removed in '
                u'Zope 5.',
                DeprecationWarning,
                stacklevel=2)
            # check to see if we are being acquiring or not
            ob = self
            while 1:
                if is_acquired(ob):
                    raise ValueError(
                        'FTP List not supported on acquired objects')
                if not hasattr(ob, '__parent__'):
                    break
                ob = aq_parent(ob)

            stat = marshal.loads(self.manage_FTPstat(REQUEST))
            id = self.getId()
            return marshal.dumps((id, stat))
示例#2
0
        def manage_FTPlist(self, REQUEST):
            """Directory listing for FTP.
            """
            warn(u'manage_FTPlist is deprecated and will be removed in '
                 u'Zope 5.', DeprecationWarning, stacklevel=2)
            out = ()

            # check to see if we are being acquiring or not
            ob = self
            while 1:
                if is_acquired(ob):
                    raise ValueError(
                        'FTP List not supported on acquired objects')
                if not hasattr(ob, '__parent__'):
                    break
                ob = aq_parent(ob)

            files = list(self.objectItems())

            # recursive ride through all subfolders (ls -R) (ajung)

            if REQUEST.environ.get('FTP_RECURSIVE', 0) == 1:
                all_files = copy.copy(files)
                for f in files:
                    if hasattr(aq_base(f[1]), 'isPrincipiaFolderish') and \
                       f[1].isPrincipiaFolderish:
                        all_files.extend(findChildren(f[1]))
                files = all_files

            # Perform globbing on list of files (ajung)

            globbing = REQUEST.environ.get('GLOBBING', '')
            if globbing:
                files = [x for x in files if fnmatch.fnmatch(x[0], globbing)]

            files.sort()

            if not (hasattr(self, 'isTopLevelPrincipiaApplicationObject')
                    and self.isTopLevelPrincipiaApplicationObject):
                files.insert(0, ('..', aq_parent(self)))
            files.insert(0, ('.', self))
            for k, v in files:
                # Note that we have to tolerate failure here, because
                # Broken objects won't stat correctly. If an object fails
                # to be able to stat itself, we will ignore it, but log
                # the error.
                try:
                    stat = marshal.loads(v.manage_FTPstat(REQUEST))
                except Exception:
                    LOG.error("Failed to stat file '%s'" % k,
                              exc_info=sys.exc_info())
                    stat = None
                if stat is not None:
                    out = out + ((k, stat),)
            return marshal.dumps(out)
    def manage_FTPlist(self, REQUEST):
        """Directory listing for FTP.
        """
        out=()

        # check to see if we are being acquiring or not
        ob=self
        while 1:
            if is_acquired(ob):
                raise ValueError('FTP List not supported on acquired objects')
            if not hasattr(ob,'aq_parent'):
                break
            ob=ob.aq_parent

        files = list(self.objectItems())

        # recursive ride through all subfolders (ls -R) (ajung)

        if REQUEST.environ.get('FTP_RECURSIVE',0) == 1:

            all_files = copy.copy(files)
            for f in files:
                if (hasattr(aq_base(f[1]), 'isPrincipiaFolderish') and
                    f[1].isPrincipiaFolderish):
                    all_files.extend(findChildren(f[1]))
            files = all_files

        # Perform globbing on list of files (ajung)

        globbing = REQUEST.environ.get('GLOBBING','')
        if globbing :
            files = [x for x in files if fnmatch.fnmatch(x[0],globbing)]

        files.sort()

        if not (hasattr(self,'isTopLevelPrincipiaApplicationObject') and
                self.isTopLevelPrincipiaApplicationObject):
            files.insert(0,('..',self.aq_parent))
        files.insert(0, ('.', self))
        for k,v in files:
            # Note that we have to tolerate failure here, because
            # Broken objects won't stat correctly. If an object fails
            # to be able to stat itself, we will ignore it, but log
            # the error.
            try:
                stat=marshal.loads(v.manage_FTPstat(REQUEST))
            except:
                LOG.error("Failed to stat file '%s'" % k,
                          exc_info=sys.exc_info())
                stat=None
            if stat is not None:
                out=out+((k,stat),)
        return marshal.dumps(out)
示例#4
0
    def manage_FTPlist(self, REQUEST):
        """Directory listing for FTP.

        In the case of non-Foldoid objects, the listing should contain one
        object, the object itself.
        """
        from App.Common import is_acquired
        # check to see if we are being acquiring or not
        ob = self
        while 1:
            if is_acquired(ob):
                raise ValueError('FTP List not supported on acquired objects')
            if not hasattr(ob, 'aq_parent'):
                break
            ob = aq_parent(ob)

        stat = marshal.loads(self.manage_FTPstat(REQUEST))
        id = self.getId()
        return marshal.dumps((id, stat))
示例#5
0
    def manage_FTPlist(self,REQUEST):
        """Directory listing for FTP.

        In the case of non-Foldoid objects, the listing should contain one
        object, the object itself.
        """
        from App.Common import is_acquired
        # check to see if we are being acquiring or not
        ob=self
        while 1:
            if is_acquired(ob):
                raise ValueError('FTP List not supported on acquired objects')
            if not hasattr(ob,'aq_parent'):
                break
            ob = aq_parent(ob)

        stat=marshal.loads(self.manage_FTPstat(REQUEST))
        id = self.getId()
        return marshal.dumps((id,stat))