diff --git a/composer/schema/factory.py b/composer/schema/factory.py index e63b27f..64dc1e9 100644 --- a/composer/schema/factory.py +++ b/composer/schema/factory.py @@ -33,7 +33,12 @@ from cybertools.composer.schema.schema import Schema class Email(schema.TextLine): - pass + + __typeInfo__ = ('email',) + + +# put field type name and other info in standard field classes. +schema.Field.__typeInfo__ = ('textline',) class SchemaFactory(object): @@ -45,8 +50,8 @@ class SchemaFactory(object): adapts(Interface) fieldMapping = { - schema.TextLine: ('textline',), - schema.ASCIILine: ('textline',), + #schema.TextLine: ('textline',), + #schema.ASCIILine: ('textline',), schema.Password: ('password',), schema.Text: ('textarea',), schema.ASCII: ('textarea',), @@ -57,7 +62,7 @@ class SchemaFactory(object): schema.List: ('list',), schema.Choice: ('dropdown',), schema.Bytes: ('fileupload',), - Email: ('email',), + #Email: ('email',), } def __init__(self, context): @@ -71,7 +76,9 @@ class SchemaFactory(object): if fname in omit: continue field = interface[fname] - info = fieldMapping.get(field.__class__) or ('textline',) + info = fieldMapping.get(field.__class__) + if info is None: + info = getattr(field, '__typeInfo__', ('textline',)) voc = (getattr(field, 'vocabulary', ()) or getattr(field, 'vocabularyName', None)) f = Field(field.getName(), diff --git a/composer/schema/instance.py b/composer/schema/instance.py index aee0cf0..f96a636 100644 --- a/composer/schema/instance.py +++ b/composer/schema/instance.py @@ -54,7 +54,6 @@ class Instance(BaseInstance): continue fi = f.getFieldInstance(self) name = f.name - #value = getattr(self.context, name, f.defaultValue) value = getattr(self.context, name) or fi.default value = (mode == 'view' and fi.display(value)) or fi.marshall(value) result[name] = value diff --git a/composer/schema/interfaces.py b/composer/schema/interfaces.py index 2a1174f..a42d0d1 100644 --- a/composer/schema/interfaces.py +++ b/composer/schema/interfaces.py @@ -82,6 +82,7 @@ class FieldType(SimpleTerm): setattr(self, k, v) +# TODO: register this object as a utility providing IFieldTypes fieldTypes = SimpleVocabulary(( FieldType('textline', 'textline', u'Textline'), FieldType('password', 'password', u'Password'),