Example #1
0
        def manage_FTPstat(self, REQUEST):
            """Psuedo stat, used by FTP for directory listings.
            """
            from AccessControl.User import nobody
            warn(
                u'manage_FTPstat is deprecated and will be removed in '
                u'Zope 5.',
                DeprecationWarning,
                stacklevel=2)
            mode = 0o0100000

            if (hasattr(aq_base(self), 'manage_FTPget')):
                try:
                    if getSecurityManager().validate(None, self,
                                                     'manage_FTPget',
                                                     self.manage_FTPget):
                        mode = mode | 0o0440
                except Unauthorized:
                    pass

                if nobody.allowed(
                        self.manage_FTPget,
                        getRoles(self, 'manage_FTPget', self.manage_FTPget,
                                 ())):
                    mode = mode | 0o0004

            # check write permissions
            if hasattr(aq_base(self), 'PUT'):
                try:
                    if getSecurityManager().validate(None, self, 'PUT',
                                                     self.PUT):
                        mode = mode | 0o0220
                except Unauthorized:
                    pass

                if nobody.allowed(self.PUT, getRoles(self, 'PUT', self.PUT,
                                                     ())):
                    mode = mode | 0o0002

            # get size
            if hasattr(aq_base(self), 'get_size'):
                size = self.get_size()
            elif hasattr(aq_base(self), 'manage_FTPget'):
                size = len(self.manage_FTPget())
            else:
                size = 0
            # get modification time
            if hasattr(aq_base(self), '_p_mtime'):
                mtime = DateTime(self._p_mtime).timeTime()
            else:
                mtime = time.time()
            # get owner and group
            owner = group = 'Zope'
            if hasattr(aq_base(self), 'get_local_roles'):
                for user, roles in self.get_local_roles():
                    if 'Owner' in roles:
                        owner = user
                        break
            return marshal.dumps(
                (mode, 0, 0, 1, owner, group, size, mtime, mtime, mtime))
Example #2
0
        def manage_FTPstat(self, REQUEST):
            """Psuedo stat, used by FTP for directory listings.
            """
            from AccessControl.User import nobody
            mode = 0o0100000

            if (hasattr(aq_base(self), 'manage_FTPget')):
                try:
                    if getSecurityManager().validate(
                            None, self, 'manage_FTPget', self.manage_FTPget):
                        mode = mode | 0o0440
                except Unauthorized:
                    pass

                if nobody.allowed(
                        self.manage_FTPget,
                        getRoles(self, 'manage_FTPget',
                                 self.manage_FTPget, ())):
                    mode = mode | 0o0004

            # check write permissions
            if hasattr(aq_base(self), 'PUT'):
                try:
                    if getSecurityManager().validate(None, self,
                                                     'PUT', self.PUT):
                        mode = mode | 0o0220
                except Unauthorized:
                    pass

                if nobody.allowed(
                        self.PUT,
                        getRoles(self, 'PUT', self.PUT, ())):
                    mode = mode | 0o0002

            # get size
            if hasattr(aq_base(self), 'get_size'):
                size = self.get_size()
            elif hasattr(aq_base(self), 'manage_FTPget'):
                size = len(self.manage_FTPget())
            else:
                size = 0
            # get modification time
            if hasattr(aq_base(self), '_p_mtime'):
                mtime = DateTime(self._p_mtime).timeTime()
            else:
                mtime = time.time()
            # get owner and group
            owner = group = 'Zope'
            if hasattr(aq_base(self), 'get_local_roles'):
                for user, roles in self.get_local_roles():
                    if 'Owner' in roles:
                        owner = user
                        break
            return marshal.dumps(
                (mode, 0, 0, 1, owner, group, size, mtime, mtime, mtime))
        def manage_FTPstat(self, REQUEST):
            """Psuedo stat, used by FTP for directory listings.
            """
            mode = 0o0040000
            from AccessControl.User import nobody
            # check to see if we are acquiring our objectValues or not
            if not (len(REQUEST.PARENTS) > 1 and self.objectValues()
                    == REQUEST.PARENTS[1].objectValues()):
                try:
                    if getSecurityManager().validate(None, self,
                                                     'manage_FTPlist',
                                                     self.manage_FTPlist):
                        mode = mode | 0o0770
                except Exception:
                    pass

                if nobody.allowed(
                        self,
                        getRoles(self, 'manage_FTPlist', self.manage_FTPlist,
                                 ())):
                    mode = mode | 0o0007
            if hasattr(aq_base(self), '_p_mtime'):
                mtime = DateTime(self._p_mtime).timeTime()
            else:
                mtime = time.time()
            # get owner and group
            owner = group = 'Zope'
            for user, roles in self.get_local_roles():
                if 'Owner' in roles:
                    owner = user
                    break
            return marshal.dumps(
                (mode, 0, 0, 1, owner, group, 0, mtime, mtime, mtime))
Example #4
0
    def manage_FTPstat(self,REQUEST):
        """Psuedo stat, used by FTP for directory listings.
        """
        mode=0040000
        from AccessControl.User import nobody
        # check to see if we are acquiring our objectValues or not
        if not (len(REQUEST.PARENTS) > 1 and
                self.objectValues() == REQUEST.PARENTS[1].objectValues()):
            try:
                if getSecurityManager().validate(
                    None, self, 'manage_FTPlist', self.manage_FTPlist
                    ):
                    mode=mode | 0770
            except: pass

            if nobody.allowed(
                self,
                getRoles(self, 'manage_FTPlist', self.manage_FTPlist, ())):
                mode=mode | 0007
        if hasattr(aq_base(self), '_p_mtime'):
            mtime = DateTime(self._p_mtime).timeTime()
        else:
            mtime = time.time()
        # get owner and group
        owner=group='Zope'
        for user, roles in self.get_local_roles():
            if 'Owner' in roles:
                owner=user
                break
        return marshal.dumps((mode,0,0,1,owner,group,0,mtime,mtime,mtime))
Example #5
0
    def manage_FTPstat(self,REQUEST):
        "psuedo stat, used by FTP for directory listings"
        from AccessControl.User import nobody
        mode=0100000

        # check read permissions
        if (hasattr(aq_base(self),'manage_FTPget') and
            hasattr(self.manage_FTPget, '__roles__')):
            try:
                if getSecurityManager().validateValue(self.manage_FTPget):
                    mode=mode | 0440
            except: pass
            if nobody.allowed(self.manage_FTPget,
                              self.manage_FTPget.__roles__):
                mode=mode | 0004

        # check write permissions
        if hasattr(aq_base(self),'PUT') and hasattr(self.PUT, '__roles__'):
            try:
                if getSecurityManager().validateValue(self.PUT):
                    mode=mode | 0220
            except: pass

            if nobody.allowed(self.PUT, self.PUT.__roles__):
                mode=mode | 0002

        # get size
        if hasattr(aq_base(self), 'get_size'):
            size=self.get_size()
        elif hasattr(aq_base(self),'manage_FTPget'):
            size=len(self.manage_FTPget())
        else:
            size=0
        # get modification time
        if hasattr(aq_base(self), 'bobobase_modification_time'):
            mtime=self.bobobase_modification_time().timeTime()
        else:
            mtime=time.time()
        # get owner and group
        owner=group='Zope'
        if hasattr(aq_base(self), 'get_local_roles'):
            for user, roles in self.get_local_roles():
                if 'Owner' in roles:
                    owner=user
                    break
        return marshal.dumps((mode,0,0,1,owner,group,size,mtime,mtime,mtime))
 def manage_FTPstat(self,REQUEST):
     "Psuedo stat used for FTP listings"
     mode=0040000
     from AccessControl.User import nobody
     # check to see if we are acquiring our objectValues or not
     if not (len(REQUEST.PARENTS) > 1 and
             self.objectValues() == REQUEST.PARENTS[1].objectValues()):
         try:
             if getSecurityManager().validateValue(self.manage_FTPlist):
                 mode=mode | 0770
         except: pass
         if nobody.allowed(
                     self.manage_FTPlist,
                     self.manage_FTPlist.__roles__):
             mode=mode | 0007
     mtime=self.bobobase_modification_time().timeTime()
     # get owner and group
     owner=group='Zope'
     for user, roles in self.get_local_roles():
         if 'Owner' in roles:
             owner=user
             break
     return marshal.dumps((mode,0,0,1,owner,group,0,mtime,mtime,mtime))