Changeset 1772 for WAeUP_SRP/trunk/Widgets.py
- Timestamp:
- 11 May 2007, 12:00:10 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Widgets.py
r1748 r1772 6 6 ##from Products.CPSSchemas.Widget import CPSWidgetType 7 7 from Products.CMFCore.utils import getToolByName 8 from Products.CPSSchemas.BasicWidgets import CPS Widget, CPSStringWidget, CPSEmailWidget,CPSImageWidget8 from Products.CPSSchemas.BasicWidgets import CPSBooleanWidget, CPSWidget, CPSStringWidget, CPSEmailWidget,CPSImageWidget 9 9 from Products.CPSSchemas.BasicWidgets import renderHtmlTag,CPSSelectWidget, CPSStringWidget 10 10 from Products.CPSSchemas.ExtendedWidgets import CPSDateTimeWidget … … 389 389 widgetRegistry.register(SecretWidget) 390 390 ###) 391 392 class WAeUPSexWidget(CPSBooleanWidget): 393 """WAeUP sex widget.""" 394 meta_type = 'WAeUP Sex Widget' 395 396 def validate(self, datastructure, **kw): 397 """Validate datastructure and update datamodel.""" 398 value = datastructure[self.getWidgetId()] 399 400 if self.render_format not in self.render_formats: 401 self.render_format = 'select' 402 403 female = value in ('F','f','Female','female',"True",True) 404 male = value in ('M','m','Male','male','False',False) 405 if not female and not male: 406 datastructure.setError(self.getWidgetId(), 407 "invalid sex %s" % value) 408 return 0 409 elif female: 410 v = True 411 else: 412 v = False 413 datamodel = datastructure.getDataModel() 414 datamodel[self.fields[0]] = v 415 return 1 416 417 InitializeClass(WAeUPSexWidget) 418 419 widgetRegistry.register(WAeUPSexWidget) 391 420 392 421 class MatricNoWidget(CPSStringWidget): ###(
Note: See TracChangeset for help on using the changeset viewer.