# HG changeset patch # User Pierre-Yves David # Date 1294332559 -3600 # Node ID 0f31ed3fff798c07e954fd18042f6339d04af564 # Parent aede8c85207fbd754c82810d956f4dcab47d7789 [bfss storage] Improve fspath() error message. This changeset improve the error message of fspath when the argument is not managed by a BytesFileSystem storage. diff -r aede8c85207f -r 0f31ed3fff79 cwconfig.py --- a/cwconfig.py Thu Jan 06 17:47:50 2011 +0100 +++ b/cwconfig.py Thu Jan 06 17:49:19 2011 +0100 @@ -1278,7 +1278,9 @@ stack[0] = self.source_execute def as_sql(self, backend, args): - raise NotImplementedError('source only callback') + raise NotImplementedError( + 'This callback is only available for BytesFileSystemStorage ' + 'managed attribute. Is FSPATH() argument BFSS managed?') def source_execute(self, source, session, value): fpath = source.binary_to_str(value) diff -r aede8c85207f -r 0f31ed3fff79 server/test/unittest_storage.py --- a/server/test/unittest_storage.py Thu Jan 06 17:47:50 2011 +0100 +++ b/server/test/unittest_storage.py Thu Jan 06 17:49:19 2011 +0100 @@ -75,6 +75,15 @@ {'f': entity.eid})[0][0] return fspath.getvalue() + def test_bfss_wrong_fspath_usage(self): + f1 = self.create_file() + self.execute('Any fspath(D) WHERE F eid %(f)s, F data D', {'f': f1.eid}) + with self.assertRaises(NotImplementedError) as cm: + self.execute('Any fspath(F) WHERE F eid %(f)s', {'f': f1.eid}) + self.assertEqual(str(cm.exception), + 'This callback is only available for BytesFileSystemStorage ' + 'managed attribute. Is FSPATH() argument BFSS managed?') + def test_bfss_storage(self): f1 = self.create_file() expected_filepath = osp.join(self.tempdir, '%s_data_%s' %