From: dreamcatcher <svn...@pl...> - 2005-06-22 22:27:13
|
Author: dreamcatcher Date: Wed Jun 22 18:19:06 2005 New Revision: 9164 Modified: ManagedFile/CMFManagedFile/trunk/content.py ManagedFile/CMFManagedFile/trunk/tests/move.txt Log: - Spicy up those tests Modified: ManagedFile/CMFManagedFile/trunk/content.py ============================================================================== --- ManagedFile/CMFManagedFile/trunk/content.py (original) +++ ManagedFile/CMFManagedFile/trunk/content.py Wed Jun 22 18:19:06 2005 @@ -245,7 +245,7 @@ # get the real computed path and make sure it exists ftool = getToolByName(container, TOOL_NAME) full_path = ftool.getFilesystemPathFor(obj, generate=True) - file_path = obj.getFilepath(generate=True) + file_path = obj.generateFilepath() # XXX not sure if this assert should be here since full_path ends up # replacing file_path #assert full_path == file_path, (full_path, file_path) @@ -389,7 +389,7 @@ return contents security.declareProtected(View, 'getFilepath') - def getFilepath(self, generate=False, REQUEST=None): + def getFilepath(self, REQUEST=None): """ Return the full pathname of the external file to which we are referring. The REQUEST parameter encapsulates information @@ -402,7 +402,15 @@ if not filename: # we haven't uploaded the file yet return '' return fspath(self, filenameOverride=filename, - createpath=False, generate=generate) + createpath=False, generate=False) + + security.declarePrivate('generateFilepath') + def generateFilepath(self): + tool = getToolByName(self, TOOL_NAME) + fspath = tool.getFilesystemPathFor + filename = self.getProperty('filename') + return fspath(self, filenameOverride=filename, + createpath=False, generate=True) security.declarePublic('__len__') def __len__(self): @@ -421,7 +429,7 @@ def get_size(self): - if os.path.isdir(self.getFilepath(REQUEST=self.REQUEST)): + if os.path.isdir(self.getFilepath()): return 0 return ExternalFile.get_size(self) @@ -494,7 +502,7 @@ self._updateProperty('filename', os.path.basename(fp)) if not file: - file_path = self.getFilepath(generate=True) + file_path = self.generateFilepath() # if only a repository move... if oldFilepath and oldFilepath != file_path: ftool.checkForReusedPath(file_path) Modified: ManagedFile/CMFManagedFile/trunk/tests/move.txt ============================================================================== --- ManagedFile/CMFManagedFile/trunk/tests/move.txt (original) +++ ManagedFile/CMFManagedFile/trunk/tests/move.txt Wed Jun 22 18:19:06 2005 @@ -39,6 +39,7 @@ Create a Managed File: + >>> upload.seek(0) >>> obj = self.makeOne(id='file1', upload_file=upload, ... context=self.f1) @@ -71,6 +72,14 @@ >>> os.path.exists(expected) True + >>> open(expected).read() + 'Breezy Brazilian' + +Try to download the file and see what comes out: + + >>> obj.download().read() + 'Breezy Brazilian' + Relative Path Policy -------------------- @@ -82,6 +91,7 @@ Create a Managed File pointing to one of the created files: + >>> upload.seek(0) >>> obj = self.makeOne(id='file2', upload_file=upload, ... context=self.f1) @@ -113,6 +123,11 @@ >>> os.path.exists(expected) True +Try to download the file and see what comes out: + + >>> obj.download().read() + 'Breezy Brazilian' + Physical Path Policy -------------------- @@ -124,6 +139,7 @@ Create a Managed File pointing to one of the created files: + >>> upload.seek(0) >>> obj = self.makeOne(id='file3', upload_file=upload, ... context=self.f1) @@ -155,6 +171,11 @@ >>> os.path.exists(expected) True +Try to download the file and see what comes out: + + >>> obj.download().read() + 'Breezy Brazilian' + Cleanup the temp directory: >>> self.cleanup_dirs.append(tmp_dir) |