diff --git a/composer/schema/field.py b/composer/schema/field.py index d3268bf..554fdba 100644 --- a/composer/schema/field.py +++ b/composer/schema/field.py @@ -154,7 +154,7 @@ class FieldInstance(object): #return toStr(value) def display(self, value): - return value + return value or u'' #return toStr(value) def unmarshall(self, value): diff --git a/composer/schema/instance.py b/composer/schema/instance.py index f96a636..2d9e967 100644 --- a/composer/schema/instance.py +++ b/composer/schema/instance.py @@ -55,7 +55,10 @@ class Instance(BaseInstance): fi = f.getFieldInstance(self) name = f.name value = getattr(self.context, name) or fi.default - value = (mode == 'view' and fi.display(value)) or fi.marshall(value) + if mode == 'view': + value = fi.display(value) + else: + value = fi.marshall(value) result[name] = value return result diff --git a/media/tests.py b/media/tests.py index acf1c02..de9cebd 100644 --- a/media/tests.py +++ b/media/tests.py @@ -18,10 +18,12 @@ dataDir = os.path.join(os.path.dirname(media.__file__), 'testdata') def clearDataDir(): for fn in os.listdir(dataDir): path = os.path.join(dataDir, fn) - if os.path.isdir(path): - for subfn in os.listdir(path): - os.unlink(os.path.join(path, subfn)) - os.rmdir(path) + if not fn.startswith('.'): + if os.path.isdir(path): + for subfn in os.listdir(path): + if not subfn.startswith('.'): + os.unlink(os.path.join(path, subfn)) + os.rmdir(path) class Test(unittest.TestCase):