more on cybertools.storage.filesystem for use with loops ExternalFile
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1546 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
3db9ce0bf0
commit
ec347fa5cf
2 changed files with 10 additions and 3 deletions
|
@ -13,4 +13,7 @@ Controlling the storage of data
|
|||
>>> storage.getDir('demo')
|
||||
'/home/.../cybertools/storage/testdata/demo'
|
||||
|
||||
|
||||
>>> from cybertools.storage.filesystem import instanceVarSubdirectoryStorage
|
||||
>>> storage = instanceVarSubdirectoryStorage()
|
||||
>>> storage.getDir('demo')
|
||||
'.../var/extfiles/demo'
|
||||
|
|
|
@ -23,6 +23,7 @@ $Id$
|
|||
"""
|
||||
|
||||
import os
|
||||
import cybertools
|
||||
from zope.interface import implements
|
||||
from cybertools.storage.interfaces import IExternalStorage
|
||||
|
||||
|
@ -47,6 +48,7 @@ class FileSystemStorage(object):
|
|||
f = open(fn, 'wb')
|
||||
f.write(data)
|
||||
f.close()
|
||||
print 'cybertools.storage: file %s written' % fn
|
||||
|
||||
def getData(self, address, params={}):
|
||||
subDir = params.get('subdirectory')
|
||||
|
@ -63,5 +65,7 @@ def explicitDirectoryStorage(dirname):
|
|||
|
||||
|
||||
def instanceVarSubdirectoryStorage(dirname=DEFAULT_DIRECTORY):
|
||||
instanceHome = '';
|
||||
return FileSystemStorage(instanceHome, dirname)
|
||||
instanceHome = os.path.dirname(os.path.dirname(os.path.dirname(
|
||||
os.path.dirname(cybertools.__file__))))
|
||||
varDir = os.path.join(instanceHome, 'var');
|
||||
return FileSystemStorage(varDir, dirname)
|
||||
|
|
Loading…
Add table
Reference in a new issue