Changeset 8175 for main/waeup.kofa/trunk/src
- Timestamp:
- 16 Apr 2012, 09:16:13 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/utils/converters.py
r7932 r8175 31 31 IObjectConverter, IResultEntryField, IFieldConverter, SubjectSource, 32 32 GradeSource) 33 from waeup.kofa.schema.interfaces import IPhoneNumber 33 34 from waeup.kofa.schoolgrades import ResultEntry 34 35 … … 134 135 unicode(num), unicode(item), 135 136 value_type, "%s.%s." % (prefix, num))) 137 return result 138 139 class PhoneNumberFieldConverter(grok.Adapter): 140 """Convert strings into dict as expected from forms feeding PhoneWidget. 141 142 If you want strings without extra-checks imported, you can use 143 schema.TextLine in your interface instead of PhoneNumber. 144 """ 145 grok.context(IPhoneNumber) 146 grok.provides(IFieldConverter) 147 148 def request_data(self, name, value, schema_field, prefix=''): 149 parts = value.split('-', 2) 150 country = '' 151 area = '' 152 ext = '' 153 if len(parts) == 3: 154 country = parts[0] 155 area = parts[1] 156 ext = parts[2] 157 elif len(parts) == 2: 158 country = parts[0] 159 ext = parts[1] 160 else: 161 ext = value 162 result = { 163 u'%s.country' % prefix: country, 164 u'%s.area' % prefix: area, 165 u'%s.ext' % prefix: ext} 136 166 return result 137 167
Note: See TracChangeset for help on using the changeset viewer.