Changeset 12327 for main/waeup.ikoba/trunk/src/waeup/ikoba/utils
- Timestamp:
- 26 Dec 2014, 20:18:17 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/utils
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/utils/converters.py
r12309 r12327 30 30 from zope.schema.interfaces import IList 31 31 from waeup.ikoba.interfaces import ( 32 IObjectConverter, IProductOption EntryField, IFieldConverter,32 IObjectConverter, IProductOptionField, IFieldConverter, 33 33 DELETION_MARKER, IGNORE_MARKER) 34 34 from waeup.ikoba.schema.interfaces import IPhoneNumber 35 from waeup.ikoba.products.productoptions import ProductOption Entry35 from waeup.ikoba.products.productoptions import ProductOption 36 36 37 37 class ExtendedCheckBoxWidget(CheckBoxWidget): … … 175 175 return result 176 176 177 class ProductOption EntryConverter(grok.Adapter):178 grok.context(IProductOption EntryField)177 class ProductOptionConverter(grok.Adapter): 178 grok.context(IProductOptionField) 179 179 grok.implements(IFieldConverter) 180 180 181 181 def request_data(self, name, value, schema_field, prefix='', 182 182 mode='create'): 183 """Turn CSV values into ProductOption Entry-compatible form data.183 """Turn CSV values into ProductOption-compatible form data. 184 184 185 185 Expects as `value` a _string_ like ``(u'mytitle', … … 194 194 where the values are tokens from appropriate sources. 195 195 196 Such dicts can be transformed into real ProductOption Entryobjects by196 Such dicts can be transformed into real ProductOption objects by 197 197 input widgets used in converters. 198 198 """ 199 199 try: 200 entry = ProductOption Entry.from_string(value)200 entry = ProductOption.from_string(value) 201 201 title, fee, currency = entry.title, entry.fee, entry.currency 202 202 except: -
main/waeup.ikoba/trunk/src/waeup/ikoba/utils/tests/test_converters.py
r12309 r12327 38 38 SimpleIkobaVocabulary, IFieldConverter, 39 39 DELETION_MARKER, IGNORE_MARKER) 40 from waeup.ikoba.products.productoptions import ProductOption EntryField40 from waeup.ikoba.products.productoptions import ProductOptionField 41 41 from waeup.ikoba.utils.converters import ( 42 42 IObjectConverter, IFieldConverter, DefaultFieldConverter, 43 ListFieldConverter, PhoneNumberFieldConverter, ProductOption EntryConverter,43 ListFieldConverter, PhoneNumberFieldConverter, ProductOptionConverter, 44 44 DefaultObjectConverter) 45 45 from waeup.ikoba.utils.helpers import attrs_to_fields … … 94 94 options = schema.List( 95 95 title = u'Options', 96 value_type = ProductOption EntryField(),96 value_type = ProductOptionField(), 97 97 required = True, 98 98 default = [], … … 137 137 obj2 = ListFieldConverter(None) 138 138 obj3 = PhoneNumberFieldConverter(None) 139 obj4 = ProductOption EntryConverter(None)139 obj4 = ProductOptionConverter(None) 140 140 verify.verifyObject(IFieldConverter, obj1) 141 141 verify.verifyObject(IFieldConverter, obj2) … … 145 145 verify.verifyClass(IFieldConverter, ListFieldConverter) 146 146 verify.verifyClass(IFieldConverter, PhoneNumberFieldConverter) 147 verify.verifyClass(IFieldConverter, ProductOption EntryConverter)147 verify.verifyClass(IFieldConverter, ProductOptionConverter) 148 148 return 149 149
Note: See TracChangeset for help on using the changeset viewer.