diff --git a/composer/schema/factory.py b/composer/schema/factory.py index 3365668..fc74718 100644 --- a/composer/schema/factory.py +++ b/composer/schema/factory.py @@ -62,19 +62,18 @@ class SchemaFactory(object): fields = [] for fname in schema.getFieldNamesInOrder(interface): field = interface[fname] - if field.__class__ in fieldMapping: - info = fieldMapping[field.__class__] - voc = (getattr(field, 'vocabulary', ()) or - getattr(field, 'vocabularyName', None)) - f = Field(field.getName(), - fieldType=info[0], - required=field.required, - default=field.default, - default_method=getattr(field, 'default_method', None), - vocabulary=voc, - title=field.title, - description=field.description, - readonly=field.readonly, - nostore=getattr(field, 'nostore', False),) - fields.append(f) + info = fieldMapping.get(field.__class__) or ('textline',) + voc = (getattr(field, 'vocabulary', ()) or + getattr(field, 'vocabularyName', None)) + f = Field(field.getName(), + fieldType=info[0], + required=field.required, + default=field.default, + default_method=getattr(field, 'default_method', None), + vocabulary=voc, + title=field.title, + description=field.description, + readonly=field.readonly, + nostore=getattr(field, 'nostore', False),) + fields.append(f) return Schema(name=interface.__name__, *fields, **kw) diff --git a/composer/schema/field.py b/composer/schema/field.py index fc17349..60874c9 100644 --- a/composer/schema/field.py +++ b/composer/schema/field.py @@ -50,6 +50,12 @@ class Field(Component): default = None default_method = None + fieldTypeInfo = None + instance_name = None + display_renderer = None + display_format = None + + def __init__(self, name, title=None, fieldType='textline', **kw): assert name self.__name__ = name @@ -80,6 +86,10 @@ class Field(Component): def inputRenderer(self): return self.getFieldTypeInfo().inputRenderer + @property + def displayRenderer(self): + return self.display_renderer or self.getFieldTypeInfo().displayRenderer + @property def storeData(self): return not self.nostore and self.getFieldTypeInfo().storeData @@ -100,10 +110,10 @@ class Field(Component): return [dict(token=t.token, title=t.title or t.value) for t in voc] def getFieldTypeInfo(self): - return fieldTypes.getTerm(self.fieldType) + return self.fieldTypeInfo or fieldTypes.getTerm(self.fieldType) def getFieldInstance(self, clientInstance=None): - instanceName = self.getFieldTypeInfo().instanceName + instanceName = self.instance_name or self.getFieldTypeInfo().instanceName fi = component.getAdapter(self, IFieldInstance, name=instanceName) fi.clientInstance = clientInstance return fi @@ -193,9 +203,10 @@ class DateFieldInstance(NumberFieldInstance): return '' view = self.clientInstance.view langInfo = view and view.languageInfo or None + format = self.context.display_format or ('dateTime', 'short') if langInfo: locale = locales.getLocale(langInfo.language) - fmt = locale.dates.getFormatter('dateTime', 'short') + fmt = locale.dates.getFormatter(*format) return fmt.format(value) return str(value) diff --git a/composer/schema/interfaces.py b/composer/schema/interfaces.py index 7966904..9983ffd 100644 --- a/composer/schema/interfaces.py +++ b/composer/schema/interfaces.py @@ -74,6 +74,7 @@ class FieldType(SimpleTerm): self.name = value self.fieldRenderer = 'field' self.inputRenderer = 'input_' + self.name + self.displayRenderer = 'display_textline' self.storeData = True self.instanceName = '' for k, v in kw.items(): diff --git a/organize/task.py b/organize/task.py index 80f1011..c0e480a 100644 --- a/organize/task.py +++ b/organize/task.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2006 Helmut Merz helmutm@cy55.de +# Copyright (c) 2008 Helmut Merz helmutm@cy55.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,6 +25,10 @@ $Id$ from zope.component import adapts from zope.interface import implements +from cybertools.organize.interfaces import ITask + class Task(object): + implements(ITask) +