Changeset 7921
- Timestamp:
- 20 Mar 2012, 00:51:19 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/schoolgrades.py
r7819 r7921 35 35 grade = FieldProperty(IResultEntry['grade']) 36 36 37 def __init__(self, subject=None, grade=None): 38 super(ResultEntry, self).__init__() 39 if subject is not None: 40 self.subject = subject 41 if grade is not None: 42 self.grade = grade 43 return 44 45 def to_string(self): 46 """A string representation that can be used in imports/export. 47 48 Returned is a unicode string of format ``(u'<SUBJ>',u'<GRADE>')``. 49 """ 50 return unicode((self.subject, self.grade)) 51 52 @classmethod 53 def from_string(cls, string): 54 """Create new ResultEntry instance based on `string`. 55 56 The string is expected to be in format as delivered by 57 meth:`to_string`. 58 59 This is a classmethod. This means, you normally will call:: 60 61 ResultEntry.from_string(mystring) 62 63 i.e. use the `ResultEntry` class, not an instance thereof. 64 """ 65 string = string.replace("u''", "None") 66 subject, grade = eval(string) 67 return cls(subject, grade) 68 37 69 class ResultEntryField(Object): 38 70 """A zope.schema-like field for usage in interfaces.
Note: See TracChangeset for help on using the changeset viewer.