added integrator package: transparent access to filesystem directories and files
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2442 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
d505f3629a
commit
76e6742b25
3 changed files with 8 additions and 4 deletions
|
@ -12,7 +12,7 @@ Getting started
|
|||
|
||||
Let's do some basic set up
|
||||
|
||||
>>> from zope import component, interface
|
||||
>>> from zope import component
|
||||
|
||||
>>> from cybertools.integrator.tests import testDir
|
||||
>>> from cybertools.integrator.filesystem import ContainerFactory, FileFactory
|
||||
|
|
|
@ -38,9 +38,12 @@ class ReadContainer(Contained):
|
|||
implements(IReadContainer)
|
||||
|
||||
factoryName = 'sample'
|
||||
__parent__ = None
|
||||
|
||||
def __init__(self, address, **kw):
|
||||
self.address = address
|
||||
for k, v in kw.items():
|
||||
setattr(self, k, v)
|
||||
|
||||
@Lazy
|
||||
def fileFactory(self):
|
||||
|
@ -85,6 +88,7 @@ class File(object):
|
|||
|
||||
contentType = None
|
||||
data = None
|
||||
__parent__ = None
|
||||
|
||||
def __init__(self, address, contentType, **kw):
|
||||
self.address = address
|
||||
|
|
|
@ -46,7 +46,7 @@ class ReadContainer(ReadContainer):
|
|||
return os.listdir(self.address)
|
||||
|
||||
def keys(self):
|
||||
return self.filenames
|
||||
return [n for n in self.filenames if not n.startswith('.')]
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.keys())
|
||||
|
@ -61,9 +61,9 @@ class ReadContainer(ReadContainer):
|
|||
return default
|
||||
path = os.path.join(self.address, key)
|
||||
if os.path.isdir(path):
|
||||
return self.containerFactory(path)
|
||||
return self.containerFactory(path, __parent__=self.__parent__)
|
||||
else:
|
||||
return self.fileFactory(path)
|
||||
return self.fileFactory(path, __parent__=self.__parent__)
|
||||
|
||||
def values(self):
|
||||
return [self.get(k) for k in self]
|
||||
|
|
Loading…
Add table
Reference in a new issue