define an email standard field

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2392 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2008-02-12 14:09:33 +00:00
parent b3eaf1e58f
commit 74e1a6301e
4 changed files with 26 additions and 3 deletions

View file

@ -46,6 +46,20 @@ correct conversion of input data to context attributes.
>>> srv.title, srv.description, srv.capacity >>> srv.title, srv.description, srv.capacity
(u'Service', u'', u'30') (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 Creating a schema from an interface
=================================== ===================================

View file

@ -32,6 +32,10 @@ from cybertools.composer.schema.interfaces import ISchemaFactory
from cybertools.composer.schema.schema import Schema from cybertools.composer.schema.schema import Schema
class Email(schema.TextLine):
pass
class SchemaFactory(object): class SchemaFactory(object):
""" Creates a cybertools.composer schema from an """ Creates a cybertools.composer schema from an
interface (a zope.schema schema). interface (a zope.schema schema).
@ -52,6 +56,7 @@ class SchemaFactory(object):
schema.Bool: ('checkbox',), schema.Bool: ('checkbox',),
schema.Choice: ('dropdown',), schema.Choice: ('dropdown',),
schema.Bytes: ('fileupload',), schema.Bytes: ('fileupload',),
Email: ('email',),
} }
def __init__(self, context): def __init__(self, context):

View file

@ -90,7 +90,8 @@ fieldTypes = SimpleVocabulary((
inputRenderer='input_textline', instanceName='number'), inputRenderer='input_textline', instanceName='number'),
FieldType('date', 'date', u'Date', instanceName='date'), FieldType('date', 'date', u'Date', instanceName='date'),
FieldType('email', 'email', u'E-Mail Address', 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', FieldType('fileupload', 'fileupload', u'File upload',
instanceName='fileupload'), instanceName='fileupload'),
FieldType('checkbox', 'checkbox', u'Checkbox', instanceName='boolean'), 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 ' fieldRenderer = Attribute('Name of a renderer (i.e. a ZPT macro or '
'an adapter) that is responsible for rendering ' 'an adapter) that is responsible for rendering '
'(presenting) the field as a whole.') '(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 ' inputRenderer = Attribute('Name of a renderer (i.e. a ZPT macro or '
'an adapter) that is responsible for rendering ' 'an adapter) that is responsible for rendering '
'(presenting) the part of the field that allows ' '(presenting) the part of the field that allows '

View file

@ -27,6 +27,7 @@ from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from zope.interface import Interface, Attribute from zope.interface import Interface, Attribute
from zope.i18nmessageid import MessageFactory from zope.i18nmessageid import MessageFactory
from cybertools.composer.schema.factory import Email
from cybertools.util.jeep import Jeep, Term from cybertools.util.jeep import Jeep, Term
_ = MessageFactory('zope') _ = MessageFactory('zope')
@ -53,8 +54,7 @@ class IPerson(Interface):
lastName = schema.TextLine( lastName = schema.TextLine(
title=_(u'Last name'), title=_(u'Last name'),
description=_(u'The last name or surname'),) description=_(u'The last name or surname'),)
email = schema.TextLine( email = Email(title=_(u'E-Mail address'),
title=_(u'E-Mail address'),
description=_(u'The standard email address of the person'),) description=_(u'The standard email address of the person'),)
phoneNumbers = SimpleList( phoneNumbers = SimpleList(
value_type=schema.TextLine(), value_type=schema.TextLine(),