Commit 9ec1d6cf authored by Yoshinori Okuji's avatar Yoshinori Okuji

Define a transactional class to delete a directory when the object is deleted.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5150 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9bf95f96
...@@ -36,9 +36,28 @@ import os ...@@ -36,9 +36,28 @@ import os
from App.config import getConfiguration from App.config import getConfiguration
from Globals import package_home from Globals import package_home
from Products.ERP5 import product_path from Products.ERP5 import product_path
from Shared.DC.ZRDB.TM import TM
from Products.ERP5.Document.BusinessTemplate import removeAll
from zLOG import LOG from zLOG import LOG
class Deletion(TM):
"""Remove the directory at the end of a transaction.
"""
def __init__(self, path):
self.path = path
self._register()
def _finish(self):
try:
LOG('Deletion', 0, 'removing %s' % self.path)
removeAll(self.path)
except OSError:
pass
def _abort(self):
pass
class ExtFolder( XMLObject ): class ExtFolder( XMLObject ):
""" """
ExtFolder stores sub-objects as ExtFile or ExtImage. ExtFolder stores sub-objects as ExtFile or ExtImage.
...@@ -93,3 +112,9 @@ class ExtFolder( XMLObject ): ...@@ -93,3 +112,9 @@ class ExtFolder( XMLObject ):
status = os.system("%s/bin/genbt5list %s" % (product_path, self._getRepositoryPath())) status = os.system("%s/bin/genbt5list %s" % (product_path, self._getRepositoryPath()))
if status != 0: if status != 0:
raise RuntimeError, "failed in executing genbt5list" raise RuntimeError, "failed in executing genbt5list"
def manage_beforeDelete(self, item, container):
"""Called before deleting this object.
"""
self._v_deletion = Deletion(self._getRepositoryPath())
XMLObject.manage_beforeDelete(self, item, container)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment