Changeset 4190 for waeup/branches
- Timestamp:
- 27 May 2009, 11:57:16 (16 years ago)
- Location:
- waeup/branches/ulif-rewrite/src/waeup
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/datacenter.py
r4186 r4190 13 13 from zope.interface import Interface 14 14 from waeup.interfaces import IWAeUPObject, IWAeUPCSVImporter, ICSVDataReceivers 15 from waeup.utils.helpers import copyFileSystemTree 15 16 from waeup.viewlets import Index, MainArea, LeftSidebar 16 17 … … 71 72 return result 72 73 73 def setStoragePath(self, path, move=False ):74 def setStoragePath(self, path, move=False, overwrite=False): 74 75 """Set the path where to store files. 75 76 """ 76 77 path = os.path.abspath(path) 78 not_copied = [] 77 79 if not os.path.exists(path): 78 80 raise ValueError('The path given does not exist: %s' % path) 79 81 if move is True: 80 # copy contents of old location to new one 81 srcdir = self.storage 82 dstdir = path 83 for item in os.listdir(srcdir): 84 if os.path.isdir(item): 85 shutil.copytree(os.path.join(srcdir, item), 86 os.path.join(dstdir, item)) 87 else: 88 shutil.copy2(os.path.join(srcdir, item), dstdir) 82 83 not_copied = copyFileSystemTree(self.storage, path, 84 overwrite=overwrite) 89 85 90 86 self.storage = path 91 87 return not_copied 92 88 93 89 def getCSVDataReceivers(self, obj): … … 244 240 grok.template('master') 245 241 246 def update(self, newpath=None, save=None, cancel=None): 242 def update(self, newpath=None, move=False, overwrite=False, 243 save=None, cancel=None): 244 if move: 245 move = True 246 if overwrite: 247 overwrite = True 247 248 if newpath is None: 248 249 return … … 251 252 return 252 253 try: 253 self.context.setStoragePath(newpath) 254 not_copied = self.context.setStoragePath(newpath, move=move) 255 for name in not_copied: 256 self.flash('File already existed (not copied): %s' % name) 254 257 except ValueError: 255 258 self.flash('Given storage path cannot be used.') … … 257 260 return 258 261 if newpath: 262 self.flash('New storage path succefully set.') 259 263 self.redirect(self.url(self.context)) 260 264 return -
waeup/branches/ulif-rewrite/src/waeup/datacenter_templates/settingsmain.pt
r4153 r4190 7 7 tal:attributes="value context/storage" /> 8 8 <br /> 9 <div> 10 <input type="checkbox" name="move" checked="checked" /> 11 <label for="move">Copy existing data to new storage?</label> 12 </div> 13 <div> 14 <input type="checkbox" name="overwrite" checked="no" /> 15 <label for="overwrite">Overwrite contents in new location?</label> 16 </div> 17 9 18 <input type="submit" name="save" value="Save" /> 10 19 <input type="reset" name="reset" value="Reset" />
Note: See TracChangeset for help on using the changeset viewer.