Ignore:
Timestamp:
16 Apr 2012, 07:49:22 (13 years ago)
Author:
uli
Message:

Add PhoneNumber? schema field and register PhoneWidget? as default edit widget for it.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/schema/field.py

    r8166 r8171  
    2424from zope.schema.vocabulary import (
    2525    SimpleVocabulary, getVocabularyRegistry, VocabularyRegistryError)
    26 from waeup.kofa.schema.interfaces import IFormattedDate
     26from waeup.kofa.schema.interfaces import IFormattedDate, IPhoneNumber
    2727
    2828class CustomizableErrorMsg(object):
     
    153153        self.show_year = show_year
    154154        return super(FormattedDate, self).__init__(*args, **kw)
     155
     156class PhoneNumber(TextLine):
     157    """A schema field for phone numbers.
     158    """
     159    implements(IPhoneNumber)
  • main/waeup.kofa/trunk/src/waeup/kofa/schema/interfaces.py

    r8166 r8171  
    1717##
    1818from zope import schema
    19 from zope.schema.interfaces import IDate
     19from zope.schema.interfaces import IDate, ITextLine
    2020
    2121class IFormattedDate(IDate):
     
    3737        default = '%Y-%m-%d',
    3838        )
     39
     40class IPhoneNumber(ITextLine):
     41    """A phone number.
     42    """
  • main/waeup.kofa/trunk/src/waeup/kofa/schema/tests/test_fields.py

    r8166 r8171  
    44from zope.interface.verify import verifyClass, verifyObject
    55from zope.schema.interfaces import IDate
    6 from waeup.kofa.schema import FormattedDate
    7 from waeup.kofa.schema.interfaces import IFormattedDate
     6from waeup.kofa.schema import FormattedDate, PhoneNumber
     7from waeup.kofa.schema.interfaces import IFormattedDate, IPhoneNumber
    88
    99class FormattedDateTests(unittest.TestCase):
     
    3232        self.assertEqual(obj.date_format, '%d.%m.%Y')
    3333        return
     34
     35class PhoneNumberTests(unittest.TestCase):
     36    # Tests for PhoneNumber field
     37    def test_iface(self):
     38        # make sure we fullfill interface contracts
     39        obj = PhoneNumber()
     40        verifyClass(IPhoneNumber, PhoneNumber)
     41        verifyObject(IPhoneNumber, obj)
     42        return
  • main/waeup.kofa/trunk/src/waeup/kofa/widgets/overrides.zcml

    r8166 r8171  
    2525      />
    2626
     27  <!-- Register edit widget for PhoneNumbers -->
     28  <adapter
     29      for="waeup.kofa.schema.interfaces.IPhoneNumber
     30           zope.publisher.interfaces.browser.IBrowserRequest"
     31      provides="zope.formlib.interfaces.ISimpleInputWidget"
     32      factory="waeup.kofa.widgets.phonewidget.PhoneWidget"
     33      permission="zope.Public"
     34      />
     35
    2736</configure>
Note: See TracChangeset for help on using the changeset viewer.