[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server/VFS - IReadFileSystem.py:1.1.2.2 IWriteFileSystem.py:1.1.2.3 ListProducer.py:1.1.2.2 MSDOSFileSystem.py:1.1.2.2 MergedFileSystem.py:1.1.2.2 OSFileSystem.py:1.1.2.10 PublisherFileSystem.py:1.1.2.2 PublisherVFSTask.py:1.1.2.2 UnixFileSystem.py:1.1.2.4 __init__.py:1.1.2.2
Shane Hathaway
shane@cvs.zope.org
Thu, 4 Apr 2002 13:46:29 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Server/VFS
In directory cvs.zope.org:/tmp/cvs-serv17993/VFS
Modified Files:
Tag: Zope3-Server-Branch
IReadFileSystem.py IWriteFileSystem.py ListProducer.py
MSDOSFileSystem.py MergedFileSystem.py OSFileSystem.py
PublisherFileSystem.py PublisherVFSTask.py UnixFileSystem.py
__init__.py
Log Message:
Just fixed line endings. No carriage returns.
=== Zope3/lib/python/Zope/Server/VFS/IReadFileSystem.py 1.1.2.1 => 1.1.2.2 ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
@@ -35,18 +35,18 @@
def isdir(path):
"""Test whether a path is a directory.
"""
-
+
def isfile(path):
"""Test whether a path is a file.
"""
-
+
def listdir(path, long=0):
"""Return a listing of the directory at 'path' The empty string
indicates the current directory. If 'long' is set, instead
return a list of (name, stat_info) tuples
"""
return list(tuple(str, str))
-
+
def longify(path):
"""Return a 'long' representation of the filename
[for the output of the LIST command]
@@ -56,7 +56,7 @@
"""Return an open file object.
"""
return file
-
+
def stat(path):
"""Return the equivalent of os.stat() on the given path:
=== Zope3/lib/python/Zope/Server/VFS/IWriteFileSystem.py 1.1.2.2 => 1.1.2.3 ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
=== Zope3/lib/python/Zope/Server/VFS/ListProducer.py 1.1.2.1 => 1.1.2.2 ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
$Id$
"""
-
+
class ListProducer:
"""Produces a string, representing a list of files. Note that not all
files will be displayed at once.
"""
-
+
def __init__ (self, file_list, long, longify, batch_size=50):
self.file_list = file_list
self.long = long
self.longify = longify
- self.batch_size = int(batch_size)
+ self.batch_size = int(batch_size)
self.done = 0
-
+
def ready(self):
if len(self.file_list):
return 1
@@ -37,7 +37,7 @@
self.done = 1
return 0
-
+
def more (self):
# Check whether we have elements in the first place
if not self.file_list:
@@ -58,4 +58,4 @@
# Remove the displayed files from the list.
self.file_list = self.file_list[self.batch_size:]
return '\r\n'.join(batch) + '\r\n'
-
+
=== Zope3/lib/python/Zope/Server/VFS/MSDOSFileSystem.py 1.1.2.1 => 1.1.2.2 ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
$Id$
"""
-
-from OSFileSystem import OSFileSystem
-
+
+from OSFileSystem import OSFileSystem
+
class MSDOSFileSystem(OSFileSystem):
"""This is a generic MS-DOS-like FileSystem. It mimics MS-DOS' output.
"""
@@ -28,7 +28,7 @@
def longify(self, (path, stat_info)):
return msdos_longify(path, stat_info)
-
+
def msdos_longify(file, stat_info):
"""This matches the output of NT's ftp server (when in MSDOS mode)
@@ -41,7 +41,7 @@
date = msdos_date (stat_info[stat.ST_MTIME])
return '%s %s %8d %s' % (date, dir, stat_info[stat.ST_SIZE], file)
-
+
def msdos_date(t):
try:
info = time.gmtime(t)
@@ -54,6 +54,6 @@
info[3] = info[3] - 12
else:
merid = 'AM'
-
+
return '%02d-%02d-%02d %02d:%02d%s' % (
info[1], info[2], info[0]%100, info[3], info[4], merid )
=== Zope3/lib/python/Zope/Server/VFS/MergedFileSystem.py 1.1.2.1 => 1.1.2.2 ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
$Id$
-"""
-
+"""
+
class MergedFileSystem:
"""A merged filesystem will let you plug other filesystems
together. We really need the equivalent of a 'mount'
capability - this seems to be the most general idea. So you'd
use a 'mount' method to place another filesystem somewhere in
the hierarchy.
-
+
Note: this is most likely how I will handle ~user directories
with the http server.
"""
def __init__ (self, *fsys):
pass
-
+
=== Zope3/lib/python/Zope/Server/VFS/OSFileSystem.py 1.1.2.9 => 1.1.2.10 ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
$Id$
"""
-
+
import os
import re
import stat
import time
-
+
from ListProducer import ListProducer
from IReadFileSystem import IReadFileSystem
@@ -28,7 +28,7 @@
class OSFileSystem:
- """Generic OS FileSystem implementation.
+ """Generic OS FileSystem implementation.
The root of this file system is a string describing the path
to the directory used as root.
@@ -37,7 +37,7 @@
__implements__ = IReadFileSystem, IWriteFileSystem
path_module = os.path
-
+
def __init__ (self, root):
self.root = root
@@ -51,7 +51,7 @@
'See Zope.Server.VFS.IReadFileSystem.IReadFileSystem'
p = self.translate(path)
return self.path_module.exists(p)
-
+
def isdir(self, path):
'See Zope.Server.VFS.IReadFileSystem.IReadFileSystem'
@@ -174,7 +174,7 @@
def write(self, fd, data):
'See Zope.Server.VFS.IWriteFileSystem.IWriteFileSystem'
return os.write(fd, data)
-
+
#
############################################################
@@ -185,13 +185,13 @@
# watch for the ever-sneaky '/+' path element
path = re.sub('/+', '/', path)
# Someone is trying to get lower than the permitted root.
- # We just ignore it.
+ # We just ignore it.
path = self.path_module.normpath(path)
if path.startswith('..') or path.startswith('../'):
path = '/'
return path
-
+
def translate (self, path):
"""We need to join together three separate path components,
and do it safely. <real_root>/<path>
@@ -202,7 +202,7 @@
"""
# Normalize the directory
path = os.sep.join(path.split('/'))
- path = self.normalize(self.path_module.join(path))
+ path = self.normalize(self.path_module.join(path))
# Prepare for joining with root
if path[0] == '/':
path = path[1:]
@@ -210,11 +210,11 @@
path = self.path_module.join(self.root, path)
return path
-
+
def __repr__ (self):
return '<Unix-Style Root:%s>' % self.root
-
-
+
+
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
@@ -240,7 +240,7 @@
try: grpname = grp.getgrgid(int(stat_info[stat.ST_GID]))[0]
except: grpname = stat_info[stat.ST_GID]
-
+
mode = ('%o' % stat_info[stat.ST_MODE])[-3:]
mode = ''.join(map (lambda x: mode_table[x], mode))
@@ -259,8 +259,8 @@
date,
file
)
-
-
+
+
def ls_date (now, t):
"""Emulate the unix 'ls' command's date field. it has two formats
- if the date is more than 180 days in the past, then it's like
=== Zope3/lib/python/Zope/Server/VFS/PublisherFileSystem.py 1.1.2.1 => 1.1.2.2 ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
$Id$
"""
-
+
import os, re
import stat
import time
-
+
from IReadFileSystem import IReadFileSystem
from IWriteFileSystem import IWriteFileSystem
@@ -28,7 +28,7 @@
class PublisherFileSystem:
- """Generic Publisher FileSystem implementation.
+ """Generic Publisher FileSystem implementation.
"""
__implements__ = IReadFileSystem, IWriteFileSystem
@@ -44,7 +44,7 @@
if env is None:
env = {}
-
+
env['command'] = command
env['path'] = path
@@ -61,7 +61,7 @@
'See Zope.Server.VFS.IReadFileSystem.IReadFileSystem'
path = self.translate(path)
return self._execute(path, 'exists')
-
+
def isdir(self, path):
'See Zope.Server.VFS.IReadFileSystem.IReadFileSystem'
@@ -165,12 +165,12 @@
def unlink(self, path):
'See Zope.Server.VFS.IWriteFileSystem.IWriteFileSystem'
pass
-
+
def write(self, fd, data):
'See Zope.Server.VFS.IWriteFileSystem.IWriteFileSystem'
pass
-
+
#
############################################################
@@ -181,13 +181,13 @@
# watch for the ever-sneaky '/+' path element
path = re.sub('/+', '/', path)
# Someone is trying to get lower than the permitted root.
- # We just ignore it.
+ # We just ignore it.
path = os.path.normpath(path)
if path.startswith('..'):
path = '/'
return path
-
+
def translate (self, path):
"""We need to join together three separate path components,
and do it safely. <real_root>/<path>
@@ -198,7 +198,7 @@
"""
# Normalize the directory
path = os.sep.join(path.split('/'))
- path = self.normalize(self.path_module.join(path))
+ path = self.normalize(self.path_module.join(path))
# Prepare for joining with root
if path[0] == '/':
path = path[1:]
@@ -206,13 +206,13 @@
path = self.path_module.join(self.root, path)
return path
-
+
def __repr__ (self):
return '<Publisher-FileSystem Root:%s>' % self.root
-
-
+
+
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
@@ -238,7 +238,7 @@
try: grpname = grp.getgrgid(int(stat_info[stat.ST_GID]))[0]
except: grpname = stat_info[stat.ST_GID]
-
+
mode = ('%o' % stat_info[stat.ST_MODE])[-3:]
mode = ''.join(map (lambda x: mode_table[x], mode))
@@ -257,8 +257,8 @@
date,
file
)
-
-
+
+
def ls_date (now, t):
"""Emulate the unix 'ls' command's date field. it has two formats
- if the date is more than 180 days in the past, then it's like
=== Zope3/lib/python/Zope/Server/VFS/PublisherVFSTask.py 1.1.2.1 => 1.1.2.2 ===
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-
-import socket
-from Zope.Server.ITask import ITask
-
-
-class FTPTask:
- """
- """
-
- __implements__ = ITask
-
-
- def __init__(self, channel, command, m_name):
- self.channel = channel
- self.m_name = m_name
- self.args = command.args
-
-
- ############################################################
- # Implementation methods for interface
- # Zope.Server.ITask
-
- def service(self):
- """Called to execute the task.
- """
- try:
- try:
- self.start()
- getattr(self, self.m_name)(self.args)
- self.finish()
- except socket.error:
- self.close_on_finish = 1
- if self.channel.adj.log_socket_errors:
- raise
- finally:
- self.channel.end_task(self.close_on_finish)
-
-
- def cancel(self):
- 'See Zope.Server.ITask.ITask'
- self.channel.close_when_done()
-
-
- def defer(self):
- 'See Zope.Server.ITask.ITask'
- pass
-
- #
- ############################################################
-
- def start(self):
- now = time.time()
- self.start_time = now
-
-
- def finish(self):
- hit_log = self.channel.server.hit_log
- if hit_log is not None:
- hit_log.log(self)
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+import socket
+from Zope.Server.ITask import ITask
+
+
+class FTPTask:
+ """
+ """
+
+ __implements__ = ITask
+
+
+ def __init__(self, channel, command, m_name):
+ self.channel = channel
+ self.m_name = m_name
+ self.args = command.args
+
+
+ ############################################################
+ # Implementation methods for interface
+ # Zope.Server.ITask
+
+ def service(self):
+ """Called to execute the task.
+ """
+ try:
+ try:
+ self.start()
+ getattr(self, self.m_name)(self.args)
+ self.finish()
+ except socket.error:
+ self.close_on_finish = 1
+ if self.channel.adj.log_socket_errors:
+ raise
+ finally:
+ self.channel.end_task(self.close_on_finish)
+
+
+ def cancel(self):
+ 'See Zope.Server.ITask.ITask'
+ self.channel.close_when_done()
+
+
+ def defer(self):
+ 'See Zope.Server.ITask.ITask'
+ pass
+
+ #
+ ############################################################
+
+ def start(self):
+ now = time.time()
+ self.start_time = now
+
+
+ def finish(self):
+ hit_log = self.channel.server.hit_log
+ if hit_log is not None:
+ hit_log.log(self)
=== Zope3/lib/python/Zope/Server/VFS/UnixFileSystem.py 1.1.2.3 => 1.1.2.4 ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
$Id$
"""
-
+
import os
from OSFileSystem import OSFileSystem
@@ -26,7 +26,7 @@
__implements__ = OSFileSystem.__implements__
-
+
class SchizophrenicUnixFileSystem(OSFileSystem):
"""This File System always wants to be called with a specific user in mind.
"""
@@ -35,17 +35,17 @@
# Get process information
- PROCESS_UID = os.getuid()
- PROCESS_EUID = os.geteuid()
- PROCESS_GID = os.getgid()
- PROCESS_EGID = os.getegid()
+ PROCESS_UID = os.getuid()
+ PROCESS_EUID = os.geteuid()
+ PROCESS_GID = os.getgid()
+ PROCESS_EGID = os.getegid()
+
-
def __init__ (self, root, persona=(None, None)):
super(SchizophrenicUnixFileSystem, self).__init__(root, wd)
self.persona = persona
-
+
def become_persona (self):
if self.persona is not (None, None):
uid, gid = self.persona
@@ -53,17 +53,17 @@
os.setegid(gid)
os.seteuid(uid)
-
+
def become_nobody (self):
if self.persona is not (None, None):
os.seteuid(self.PROCESS_UID)
os.setegid(self.PROCESS_GID)
-
+
############################################################
# Implementation methods for interface
# Zope.Server.VFS.IReadFileSystem.IReadFileSystem
-
+
def open (self, filename, mode):
'See Zope.Server.VFS.IReadFileSystem.IReadFileSystem'
try:
@@ -73,7 +73,7 @@
finally:
self.become_nobody()
-
+
def listdir (self, path, long=0):
'See Zope.Server.VFS.IReadFileSystem.IReadFileSystem'
try:
=== Zope3/lib/python/Zope/Server/VFS/__init__.py 1.1.2.1 => 1.1.2.2 ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""