Changeset 6819


Ignore:
Timestamp:
27 Sep 2011, 08:07:54 (13 years ago)
Author:
Henrik Bettermann
Message:

We should be very strict when importing dates and allow only one import format: YYYY-MM-DD.

Overwrite the DateWidget? by the FormattedDateWidget?, already defined in the widgets package, to generally bypass Python's parseDatetimetz module which is used by the original DateWidget?. parseDatetimetz is too dangerous when used in importers.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/utils
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/overrides.zcml

    r6278 r6819  
    99      />
    1010
     11  <adapter
     12      for="zope.schema.interfaces.IDate
     13           zope.publisher.interfaces.browser.IBrowserRequest"
     14      provides="zope.formlib.interfaces.ISimpleInputWidget"
     15      factory="waeup.sirp.widgets.datewidget.FormattedDateWidget"
     16      permission="zope.Public"
     17      />
     18
    1119</configure>
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/tests/test_converters.py

    r6743 r6819  
    250250        contact = Contact()
    251251        converter = IObjectConverter(IContact) # a converter to IContact
    252         err, inv_err, data = converter.fromStringDict(
    253             dict(birthday='1945/12/23'), contact)
     252
     253        # The input format for dates: YYYY-MM-DD
     254        err, inv_err, data = converter.fromStringDict(
     255            dict(birthday='1945-12-23'), contact)
    254256        assert data['birthday'] == datetime.date(1945, 12, 23)
    255257        assert isinstance(data['birthday'], datetime.date)
    256258
    257259        err, inv_err, data = converter.fromStringDict(
    258             dict(birthday='1945/23/12'), contact)
    259         assert data['birthday'] == datetime.date(1945, 12, 23)
    260 
    261         # The preferred input format for dates: YYYY-MM-DD
    262         err, inv_err, data = converter.fromStringDict(
    263             dict(birthday='1945-12-23'), contact)
    264         assert data['birthday'] == datetime.date(1945, 12, 23)
     260            dict(birthday='1945-23-12'), contact)
     261        #import pdb; pdb.set_trace()
     262        #assert data['birthday'] == datetime.date(1945, 12, 23)
     263        assert err[0][1] =='Invalid datetime data'
    265264
    266265        # '08' is not interpreted as octal number
Note: See TracChangeset for help on using the changeset viewer.