From 74e1a6301ee4cac1d1cf9c13ad43ff034504db26 Mon Sep 17 00:00:00 2001 From: helmutm Date: Tue, 12 Feb 2008 14:09:33 +0000 Subject: [PATCH] define an email standard field git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2392 fd906abe-77d9-0310-91a1-e0d9ade77398 --- composer/schema/README.txt | 14 ++++++++++++++ composer/schema/factory.py | 5 +++++ composer/schema/interfaces.py | 6 +++++- organize/interfaces.py | 4 ++-- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/composer/schema/README.txt b/composer/schema/README.txt index aea0013..1dbcc15 100644 --- a/composer/schema/README.txt +++ b/composer/schema/README.txt @@ -46,6 +46,20 @@ correct conversion of input data to context attributes. >>> srv.title, srv.description, srv.capacity (u'Service', u'', u'30') +Field types +----------- + + >>> from cybertools.composer.schema.interfaces import fieldTypes + >>> sorted(t.token for t in fieldTypes) + ['checkbox', 'date', 'display', 'dropdown', 'email', 'fileupload', 'html', + 'number', 'password', 'spacer', 'textarea', 'textline'] + + >>> from zope.schema.vocabulary import SimpleVocabulary + >>> textFieldTypes = SimpleVocabulary([t for t in fieldTypes if t.token in + ... ('textline', 'textarea',)]) + >>> sorted(t.token for t in textFieldTypes) + ['textarea', 'textline'] + Creating a schema from an interface =================================== diff --git a/composer/schema/factory.py b/composer/schema/factory.py index fc74718..f9f1275 100644 --- a/composer/schema/factory.py +++ b/composer/schema/factory.py @@ -32,6 +32,10 @@ from cybertools.composer.schema.interfaces import ISchemaFactory from cybertools.composer.schema.schema import Schema +class Email(schema.TextLine): + pass + + class SchemaFactory(object): """ Creates a cybertools.composer schema from an interface (a zope.schema schema). @@ -52,6 +56,7 @@ class SchemaFactory(object): schema.Bool: ('checkbox',), schema.Choice: ('dropdown',), schema.Bytes: ('fileupload',), + Email: ('email',), } def __init__(self, context): diff --git a/composer/schema/interfaces.py b/composer/schema/interfaces.py index 9983ffd..499b508 100644 --- a/composer/schema/interfaces.py +++ b/composer/schema/interfaces.py @@ -90,7 +90,8 @@ fieldTypes = SimpleVocabulary(( inputRenderer='input_textline', instanceName='number'), FieldType('date', 'date', u'Date', instanceName='date'), FieldType('email', 'email', u'E-Mail Address', - inputRenderer='input_textline', instanceName='email'), + displayRenderer='display_email', inputRenderer='input_textline', + instanceName='email'), FieldType('fileupload', 'fileupload', u'File upload', instanceName='fileupload'), FieldType('checkbox', 'checkbox', u'Checkbox', instanceName='boolean'), @@ -172,6 +173,9 @@ class IField(IComponent): fieldRenderer = Attribute('Name of a renderer (i.e. a ZPT macro or ' 'an adapter) that is responsible for rendering ' '(presenting) the field as a whole.') + displayRenderer = Attribute('Name of a renderer (i.e. a ZPT macro or ' + 'an adapter) that is responsible for displaying ' + 'field data.') inputRenderer = Attribute('Name of a renderer (i.e. a ZPT macro or ' 'an adapter) that is responsible for rendering ' '(presenting) the part of the field that allows ' diff --git a/organize/interfaces.py b/organize/interfaces.py index 6c1feba..6b3742f 100644 --- a/organize/interfaces.py +++ b/organize/interfaces.py @@ -27,6 +27,7 @@ from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from zope.interface import Interface, Attribute from zope.i18nmessageid import MessageFactory +from cybertools.composer.schema.factory import Email from cybertools.util.jeep import Jeep, Term _ = MessageFactory('zope') @@ -53,8 +54,7 @@ class IPerson(Interface): lastName = schema.TextLine( title=_(u'Last name'), description=_(u'The last name or surname'),) - email = schema.TextLine( - title=_(u'E-Mail address'), + email = Email(title=_(u'E-Mail address'), description=_(u'The standard email address of the person'),) phoneNumbers = SimpleList( value_type=schema.TextLine(),