Changeset 10635 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 21 Sep 2013, 09:12:09 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/university/department.py
r10634 r10635 23 23 from zope.interface import implementedBy 24 24 from zope.component import getUtility 25 from zope.schema import getFields 25 26 from waeup.kofa.university.faculty import longtitle 26 27 from waeup.kofa.university.coursescontainer import CoursesContainer 27 28 from waeup.kofa.university.certificatescontainer import CertificatesContainer 28 29 from waeup.kofa.utils.batching import VirtualExportJobContainer 29 from waeup.kofa.interfaces import IKofaUtils 30 from waeup.kofa.interfaces import IKofaUtils, IKofaPluggable 30 31 from waeup.kofa.utils.helpers import attrs_to_fields 31 32 from waeup.kofa.university.interfaces import IDepartment, IDepartmentAdd … … 71 72 self.certificates.__parent__ = self 72 73 self.certificates.__name__ = 'certificates' 74 self.score_editing_disabled = False 73 75 74 76 def traverse(self, name): … … 90 92 return longtitle(self) 91 93 92 # Set all attributes of Department required in IDepartment as field93 # properties. Doing this, we do not have to set initial attributes94 # ourselves and as a bonus we get free validation when an attribute is95 # set.96 Department = attrs_to_fields(Department)97 98 94 class DepartmentFactory(grok.GlobalUtility): 99 95 """A factory for department containers. … … 111 107 """ 112 108 return implementedBy(Department) 109 110 class DepartmentsPlugin(grok.GlobalUtility): 111 """A plugin that updates courses. 112 """ 113 114 grok.implements(IKofaPluggable) 115 grok.name('departments') 116 117 deprecated_attributes = [] 118 119 def setup(self, site, name, logger): 120 return 121 122 def update(self, site, name, logger): 123 items = getFields(IDepartment).items() 124 for faculty in site['faculties'].values(): 125 for department in faculty.values(): 126 # Add new attributes 127 for i in items: 128 if not hasattr(department,i[0]): 129 setattr(department,i[0],i[1].missing_value) 130 logger.info( 131 'DepartmentsPlugin: %s attribute %s added.' % ( 132 department.code,i[0])) 133 # Remove deprecated attributes 134 for i in self.deprecated_attributes: 135 try: 136 delattr(department,i) 137 logger.info( 138 'DepartmentsPlugin: %s attribute %s deleted.' % ( 139 department.code,i)) 140 except AttributeError: 141 pass 142 return
Note: See TracChangeset for help on using the changeset viewer.