Changeset 7785 for main/waeup.sirp/branches/ulif-schoolgrades/src
- Timestamp:
- 7 Mar 2012, 23:10:44 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/branches/ulif-schoolgrades/src/waeup/sirp/schoolgrades.py
r7779 r7785 19 19 """ 20 20 import grok 21 from zope.formlib.interfaces import IInputWidget, IDisplayWidget 22 from zope.publisher.interfaces.browser import IBrowserRequest 21 23 from zope.schema.fieldproperty import FieldProperty 24 from zope.schema.interfaces import IObject 25 from zope.schema import Object 22 26 from waeup.sirp.interfaces import IResultEntry 27 from waeup.sirp.widgets.objectwidget import ( 28 SIRPObjectWidget, SIRPObjectDisplayWidget 29 ) 23 30 24 31 class ResultEntry(grok.Model): 25 """A result entry contain inga subject and a grade.32 """A result entry contains a subject and a grade. 26 33 """ 27 34 grok.implements(IResultEntry) 28 35 subject = FieldProperty(IResultEntry['subject']) 29 36 grade = FieldProperty(IResultEntry['grade']) 37 38 class IResultEntryField(IObject): 39 """A zope.schema-like field for usage in interfaces. 40 41 Marker interface to distuingish result entries from ordinary 42 object fields. Needed for registration of widgets. 43 """ 44 45 class ResultEntryField(Object): 46 """A zope.schema-like field for usage in interfaces. 47 48 If you want to define an interface containing result entries, you 49 can do so like this:: 50 51 class IMyInterface(Interface): 52 my_result_entry = ResultEntryField() 53 54 Default widgets are registered to render result entry fields. 55 """ 56 grok.implements(IResultEntryField) 57 58 def __init__(self, **kw): 59 super(ResultEntryField, self).__init__(IResultEntry, **kw) 60 return 61 62 # register SIRPObjectWidgets as default widgets for IResultEntryFields 63 @grok.adapter(IResultEntryField, IBrowserRequest) 64 @grok.implementer(IInputWidget) 65 def result_entry_input_widget(obj, req): 66 return SIRPObjectWidget(obj, req, ResultEntry) 67 68 # register a display widget for IResultEntryFields 69 @grok.adapter(IResultEntryField, IBrowserRequest) 70 @grok.implementer(IDisplayWidget) 71 def result_entry_display_widget(obj, req): 72 return SIRPObjectDisplayWidget(obj, req, ResultEntry)
Note: See TracChangeset for help on using the changeset viewer.