[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server/VFS - TestFilesystemAccess.py:1.1.2.1 UsernamePassword.py:1.1.2.1 PublisherFileSystem.py:1.1.2.8 ListProducer.py:NONE MSDOSFileSystem.py:NONE MergedFileSystem.py:NONE UnixFileSystem.py:NONE
Stephan Richter
srichter@cbu.edu
Thu, 11 Apr 2002 00:32:13 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Server/VFS
In directory cvs.zope.org:/tmp/cvs-serv25892/lib/python/Zope/Server/VFS
Modified Files:
Tag: Zope3-Server-Branch
PublisherFileSystem.py
Added Files:
Tag: Zope3-Server-Branch
TestFilesystemAccess.py UsernamePassword.py
Removed Files:
Tag: Zope3-Server-Branch
ListProducer.py MSDOSFileSystem.py MergedFileSystem.py
UnixFileSystem.py
Log Message:
Wee, quiet a bit of changes, but they fix and finnish the stuff Shane did
earlier today.
- Removed a lot of old files and moved some to more appropriate places. The
removal of the Suthentication directory is probably the biggest one. I
also deleted all the other FileSystem types, like MSDOS and Unix, since
the FielSystem is not returning formatted lists anymore. Yipee!
- Fixed PublisherFTPServer, so it works with Shane's new Credentials
interfaces. Everything should be working fine again.
- Fixed the POP3 and SMTP code to work with the new model. It all works
really well. I hope that Gerson Kurz will take over this development
soon. I also contacted authors of other server protocols, and they might
join. Rich Salz is already writing a method for ZSI, so that we can
insert SOAP in the next days.
- Made most tests run again and updated them. I still have one error. I know
why it is caused, but I do not know how to correct. I know it is a test
environment problem though, not a code one.
=== Added File Zope3/lib/python/Zope/Server/VFS/TestFilesystemAccess.py ===
##############################################################################
#
# 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.
#
##############################################################################
"""Implementation of IFilesystemAccess intended only for testing.
$Id: TestFilesystemAccess.py,v 1.1.2.1 2002/04/11 04:32:11 srichter Exp $
"""
from Zope.Server.VFS.IFilesystemAccess import IFilesystemAccess
from Zope.Server.VFS.IUsernamePassword import IUsernamePassword
from Zope.Exceptions import Unauthorized
class TestFilesystemAccess:
__implements__ = IFilesystemAccess
passwords = {'foo': 'bar'}
def __init__(self, fs):
self.fs = fs
def authenticate(self, credentials):
if not IUsernamePassword.isImplementedBy(credentials):
raise Unauthorized
name = credentials.getUserName()
if not self.passwords.has_key(name):
raise Unauthorized
if credentials.getPassword() != self.passwords[name]:
raise Unauthorized
def open(self, credentials):
self.authenticate(credentials)
return self.fs
def hasUser(self, username):
return self.passwords.has_key(username)
def getPassword(self, username):
return self.passwords.get(username, None)
=== Added File Zope3/lib/python/Zope/Server/VFS/UsernamePassword.py ===
##############################################################################
#
# 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: UsernamePassword.py,v 1.1.2.1 2002/04/11 04:32:11 srichter Exp $
"""
from Zope.Server.VFS.IUsernamePassword import IUsernamePassword
class UsernamePassword:
__implements__ = IUsernamePassword
def __init__(self, username, password):
self.username = username
self.password = password
def getUserName(self):
return self.username
def getPassword(self):
return self.password
=== Zope3/lib/python/Zope/Server/VFS/PublisherFileSystem.py 1.1.2.7 => 1.1.2.8 ===
from IWriteFileSystem import IWriteFileSystem
-from Zope.App.Security.PrincipalRegistry import principalRegistry
from Zope.Publisher.Publish import publish
-from ListProducer import ListProducer
class PublisherFileSystem:
@@ -37,46 +35,25 @@
__implements__ = IReadFileSystem, IWriteFileSystem
path_module = os.path
- request_factory = None
+ def __init__ (self, credentials, request_factory):
+ self.credentials = credentials
+ self.request_factory = request_factory
- def __init__ (self, root, username, password):
- self.root = root
- self.username = username
- self.password = password
-
-
-
- def _create_request(self, env):
- env['username'] = self.username
- env['password'] = self.password
- request = self.request_factory(StringIO(''), StringIO(), env)
- return request
def _execute(self, path, command, env=None):
-
if env is None:
env = {}
env['command'] = command
env['path'] = path
-
- request = self._create_request(env)
+ env['credentials'] = self.credentials
+ request = self.request_factory(StringIO(''), StringIO(), env)
# Note that publish() calls close() on request, which deletes the
- # response from the request, so that we need to keep trakc of it.
+ # response from the request, so that we need to keep track of it.
response = request.getResponse()
publish(request)
- return response.getResult()
-
-
- def _authenticate(self):
- request = self._create_request({})
- id = principalRegistry.authenticate(request)
- if id is None:
- return 0
- else:
- return 1
-
+ return response.getResult()
############################################################
@@ -192,7 +169,7 @@
# utility methods
- def normalize (self, path):
+ def normalize(self, path):
# watch for the ever-sneaky '/+' path element
path = re.sub('/+', '/', path)
# Someone is trying to get lower than the permitted root.
@@ -203,7 +180,7 @@
return path
- def translate (self, path):
+ def translate(self, path):
"""We need to join together three separate path components,
and do it safely. <real_root>/<path>
use the operating system's path separator.
@@ -221,5 +198,5 @@
return path
- def __repr__ (self):
+ def __repr__(self):
return '<Publisher-FileSystem Root:Data.fs>'
=== Removed File Zope3/lib/python/Zope/Server/VFS/ListProducer.py ===
=== Removed File Zope3/lib/python/Zope/Server/VFS/MSDOSFileSystem.py ===
=== Removed File Zope3/lib/python/Zope/Server/VFS/MergedFileSystem.py ===
=== Removed File Zope3/lib/python/Zope/Server/VFS/UnixFileSystem.py ===