Esempio n. 1
0
 def DISABLED_testManageHTTPUploadRegistersPreviewWithTMIfAutogen(self):
     self.addExtImage(id='image', file='')
     self.image.manage_file_upload(file=jpegImage, is_preview=1)
     self.image._v_begin_called = 0  # Clear
     TM.remove(self.image)  # Clear
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 0)
     self.image.manage_http_upload(url=self.app.GifImage.absolute_url())
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 1)
Esempio n. 2
0
 def testCreatePrevRegistersWithTM(self):
     self.addExtImage(id='image', file=jpegImage)
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 1)
     self.image._v_begin_called = 0  # Clear
     TM.remove(self.image)  # Clear
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 0)
     self.image.manage_create_prev(maxx=10, maxy=10)
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 1)
Esempio n. 3
0
 def DISABLED_testManageHTTPUploadRegistersPreviewWithTMIfAutogen(self):
     self.addExtImage(id='image', file='')
     self.image.manage_file_upload(file=jpegImage, is_preview=1)
     self.image._v_begin_called = 0  # Clear
     TM.remove(self.image)           # Clear
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 0)
     self.image.manage_http_upload(url=self.app.GifImage.absolute_url())
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 1)
Esempio n. 4
0
 def testCreatePrevRegistersWithTM(self):
     self.addExtImage(id='image', file=jpegImage)
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 1)
     self.image._v_begin_called = 0  # Clear
     TM.remove(self.image)           # Clear
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 0)
     self.image.manage_create_prev(maxx=10, maxy=10)
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 1)
Esempio n. 5
0
 def testUndoRegistersWithTM(self):
     self.addExtFile(id='file', file=notImage)
     os.rename(self._fsname('file.exe.tmp'), self._fsname('file.exe.undo'))
     self.file._v_begin_called = 0   # Clear
     TM.remove(self.file)            # Clear
     self.assertEqual(getattr(self.file, '_v_begin_called', 0), 0)
     self.file._undo()
     self.assertEqual(getattr(self.file, '_v_begin_called', 0), 1)
     self.failUnless(self._exists('file.exe.tmp'))
Esempio n. 6
0
 def testUndoRegistersWithTM(self):
     self.addExtFile(id='file', file=notImage)
     os.rename(self._fsname('file.exe.tmp'), self._fsname('file.exe.undo'))
     self.file._v_begin_called = 0  # Clear
     TM.remove(self.file)  # Clear
     self.assertEqual(getattr(self.file, '_v_begin_called', 0), 0)
     self.file._undo(self.file.filename)
     self.assertEqual(getattr(self.file, '_v_begin_called', 0), 1)
     self.failUnless(self._exists('file.exe.tmp'))
Esempio n. 7
0
 def testManageAfterCloneRegistersWithTM(self):
     self.addExtFile(id='file', file=notImage)
     self.file._finish()
     self.file._v_begin_called = 0  # Clear
     TM.remove(self.file)  # Clear
     transaction.savepoint(1)  # Need a _p_oid
     self.assertEqual(getattr(self.subfolder.file, '_v_begin_called', 0), 0)
     self.subfolder.manage_clone(self.file, 'file')
     self.assertEqual(getattr(self.subfolder.file, '_v_begin_called', 0), 1)
Esempio n. 8
0
 def testManageAfterCloneRegistersWithTM(self):
     self.addExtFile(id='file', file=notImage)
     self.file._finish()
     self.file._v_begin_called = 0   # Clear
     TM.remove(self.file)            # Clear
     transaction.savepoint(1) # Need a _p_oid
     self.assertEqual(getattr(self.subfolder.file, '_v_begin_called', 0), 0)
     self.subfolder.manage_clone(self.file, 'file')
     self.assertEqual(getattr(self.subfolder.file, '_v_begin_called', 0), 1)
Esempio n. 9
0
 def DISABLED_testPUTRegistersPreviewWithTMIfAutogen(self):
     self.addExtImage(id='image', file='')
     self.image.manage_file_upload(file=jpegImage, is_preview=1)
     self.image._v_begin_called = 0  # Clear
     TM.remove(self.image)           # Clear
     request = self.app.REQUEST
     request['BODYFILE'] = open(jpegImage, 'rb')
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 0)
     self.image.PUT(request, request.RESPONSE)
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 1)
Esempio n. 10
0
 def testUndoRegistersPreviewWithTM(self):
     self.addExtImage(id='image', file='')
     self.image.manage_file_upload(file=jpegImage, is_preview=1)
     os.rename(self._fsname('image.jpg.tmp'), self._fsname('image.jpg.undo'))
     self.image._v_begin_called = 0  # Clear
     TM.remove(self.image)           # Clear
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 0)
     self.image._undo()
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 1)
     self.failUnless(self._exists('image.jpg.tmp'))
Esempio n. 11
0
 def DISABLED_testPUTRegistersPreviewWithTMIfAutogen(self):
     self.addExtImage(id='image', file='')
     self.image.manage_file_upload(file=jpegImage, is_preview=1)
     self.image._v_begin_called = 0  # Clear
     TM.remove(self.image)  # Clear
     request = self.app.REQUEST
     request['BODYFILE'] = open(jpegImage, 'rb')
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 0)
     self.image.PUT(request, request.RESPONSE)
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 1)
Esempio n. 12
0
 def testUndoRegistersPreviewWithTM(self):
     self.addExtImage(id='image', file='')
     self.image.manage_file_upload(file=jpegImage, is_preview=1)
     os.rename(self._fsname('image.jpg.tmp'),
               self._fsname('image.jpg.undo'))
     self.image._v_begin_called = 0  # Clear
     TM.remove(self.image)  # Clear
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 0)
     self.image._undo(self.image.prev_filename)
     self.assertEqual(getattr(self.image, '_v_begin_called', 0), 1)
     self.failUnless(self._exists('image.jpg.tmp'))
Esempio n. 13
0
 def testGetUfnRegistersWithTM(self):
     self.addExtFile(id='file', file=notImage)
     self.file._finish()
     self.file._v_begin_called = 0  # Clear
     TM.remove(self.file)  # Clear
     self.file._delete(self.file.filename)  # _get_ufn will attempt to undo
     self.assertEqual(getattr(self.file, '_v_begin_called', 0), 0)
     self.failUnless(self._exists('file.exe.undo'))
     self.file._get_ufn(self.file.filename)
     self.assertEqual(getattr(self.file, '_v_begin_called', 0), 1)
     self.failUnless(self._exists('file.exe.tmp'))
     self.failIf(self._exists('file.exe.undo'))
Esempio n. 14
0
 def testGetUfnRegistersWithTM(self):
     self.addExtFile(id='file', file=notImage)
     self.file._finish()
     self.file._v_begin_called = 0   # Clear
     TM.remove(self.file)            # Clear
     self.file._delete(self.file.filename) # _get_ufn will attempt to undo
     self.assertEqual(getattr(self.file, '_v_begin_called', 0), 0)
     self.failUnless(self._exists('file.exe.undo'))
     self.file._get_ufn(self.file.filename)
     self.assertEqual(getattr(self.file, '_v_begin_called', 0), 1)
     self.failUnless(self._exists('file.exe.tmp'))
     self.failIf(self._exists('file.exe.undo'))
Esempio n. 15
0
 def _abort(self):
     """ Deletes the temporary file """
     self._v_abort_called = 1  # for tests
     TM.remove(self)  # for tests
     if self.filename:
         tmp_fn = self._temp_fsname(self.filename)
         if _debug: logger.info('aborting %s' % tmp_fn)
         if isfile(tmp_fn):
             if _debug: logger.info('isfile %s' % tmp_fn)
             try:
                 os.remove(tmp_fn)
             except OSError:
                 logger.error('_abort', exc_info=True)
Esempio n. 16
0
 def _abort(self):
     """ Deletes the temporary file """
     self._v_abort_called = 1    # for tests
     TM.remove(self)             # for tests
     if self.filename:
         tmp_fn = self._temp_fsname(self.filename)
         if _debug: logger.info('aborting %s' % tmp_fn)
         if isfile(tmp_fn):
             if _debug: logger.info('isfile %s' % tmp_fn)
             try:
                 os.remove(tmp_fn)
             except OSError:
                 logger.error('_abort', exc_info=True)
Esempio n. 17
0
 def _abort(self):
     """ Deletes the temporary file """
     self._v_abort_called = 1  # for tests
     TM.remove(self)  # for tests
     if self.filename:
         tmp_fn = self._temp_fsname(self.filename)
         if _debug:
             LOG(_SUBSYS, INFO, "aborting %s" % tmp_fn)
         if isfile(tmp_fn):
             if _debug:
                 LOG(_SUBSYS, INFO, "isfile %s" % tmp_fn)
             try:
                 os.remove(tmp_fn)
             except OSError:
                 pass
Esempio n. 18
0
 def _finish(self):
     """ Commits the temporary file """
     self._v_finish_called = 1  # for tests
     TM.remove(self)  # for tests
     if self.filename:
         tmp_fn = self._temp_fsname(self.filename)
         if _debug:
             LOG(_SUBSYS, INFO, "finishing %s" % tmp_fn)
         if isfile(tmp_fn):
             if _debug:
                 LOG(_SUBSYS, INFO, "isfile %s" % tmp_fn)
             fn = self._fsname(self.filename)
             try:
                 os.remove(fn)
             except OSError:
                 pass
             os.rename(tmp_fn, fn)
Esempio n. 19
0
 def testUploadFileIntoExistingInSeparateTransactions(self):
     # Create a file 'fred'
     self.addExtFile(id='fred', file=notImage)
     self.failUnless(TM.contains(self.file))
     self.failUnless(self._exists('fred.exe.tmp'))
     transaction.commit()
     self.failIf(TM.contains(self.file))
     self.failUnless(self._exists('fred.exe'))
     self.failIf(self._exists('fred.exe.tmp'))
     # Upload new file into 'fred'
     self.file.manage_file_upload(file=gifImage)
     self.failUnless(TM.contains(self.file))
     self.failUnless(self._exists('fred.exe'))
     self.failUnless(self._exists('fred.exe.tmp'))
     transaction.commit()
     self.failIf(TM.contains(self.file))
     self.failUnless(self._exists('fred.exe'))
     self.failIf(self._exists('fred.exe.tmp'))
Esempio n. 20
0
 def testUploadFileIntoExistingInSeparateTransactions(self):
     # Create a file 'fred'
     self.addExtFile(id='fred', file=notImage)
     self.failUnless(TM.contains(self.file))
     self.failUnless(self._exists('fred.exe.tmp'))
     transaction.commit()
     self.failIf(TM.contains(self.file))
     self.failUnless(self._exists('fred.exe'))
     self.failIf(self._exists('fred.exe.tmp'))
     # Upload new file into 'fred'
     self.file.manage_file_upload(file=gifImage)
     self.failUnless(TM.contains(self.file))
     self.failUnless(self._exists('fred.exe'))
     self.failUnless(self._exists('fred.exe.tmp'))
     transaction.commit()
     self.failIf(TM.contains(self.file))
     self.failUnless(self._exists('fred.exe'))
     self.failIf(self._exists('fred.exe.tmp'))
Esempio n. 21
0
 def _finish(self):
     """ Commits the temporary file """
     self._v_finish_called = 1   # for tests
     TM.remove(self)             # for tests
     if self.filename:
         tmp_fn = self._temp_fsname(self.filename)
         if _debug: logger.info('finishing %s' % tmp_fn)
         if isfile(tmp_fn):
             if _debug: logger.info('isfile %s' % tmp_fn)
             fn = self._fsname(self.filename)
             if isfile(fn):
                 try:
                     os.remove(fn)
                 except OSError:
                     logger.error('_finish', exc_info=True)
             try:
                 os.rename(tmp_fn, fn)
             except OSError:
                 logger.error('_finish', exc_info=True)
Esempio n. 22
0
 def _finish(self):
     """ Commits the temporary file """
     self._v_finish_called = 1  # for tests
     TM.remove(self)  # for tests
     if self.filename:
         tmp_fn = self._temp_fsname(self.filename)
         if _debug: logger.info('finishing %s' % tmp_fn)
         if isfile(tmp_fn):
             if _debug: logger.info('isfile %s' % tmp_fn)
             fn = self._fsname(self.filename)
             if isfile(fn):
                 try:
                     os.remove(fn)
                 except OSError:
                     logger.error('_finish', exc_info=True)
             try:
                 os.rename(tmp_fn, fn)
             except OSError:
                 logger.error('_finish', exc_info=True)
Esempio n. 23
0
 def _register(self):
     if _debug: logger.info('registering %s' % TM.contains(self))
     TM.register(self)
     if _debug: logger.info('registered %s' % TM.contains(self))
Esempio n. 24
0
 def _register(self):
     if _debug:
         LOG(_SUBSYS, INFO, "registering %s" % TM.contains(self))
     TM.register(self)
     if _debug:
         LOG(_SUBSYS, INFO, "registered %s" % TM.contains(self))
Esempio n. 25
0
 def _register(self):
     if _debug: logger.info('registering %s' % TM.contains(self))
     TM.register(self)
     if _debug: logger.info('registered %s' % TM.contains(self))