Ignore:
Timestamp:
21 Sep 2012, 11:21:05 (12 years ago)
Author:
uli
Message:

Merge changes from uli-async-update back into trunk.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/university
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/university/course.py

    r9170 r9217  
    2121from zope.catalog.interfaces import ICatalog
    2222from zope.interface import implementedBy
    23 from zope.schema import getFields
    24 from zope.intid.interfaces import IIntIds
    2523from zope.component import getUtility
    2624from zope.component.interfaces import IFactory, ComponentLookupError
    27 from waeup.kofa.interfaces import IKofaPluggable
    2825from waeup.kofa.university.interfaces import ICourse, ICourseAdd
    2926
     
    4037                 credits=0,
    4138                 passmark=40,
    42                  semester=1,
    43                  former_course=False,
    44                  **kw):
     39                 semester=1, **kw):
    4540        super(Course, self).__init__(**kw)
    4641        self.title = title
     
    4944        self.passmark = passmark
    5045        self.semester = semester
    51         self.former_course = former_course
    5246
    5347    def longtitle(self):
     
    8983        cert._p_changed = True
    9084    return
    91 
    92 class CoursesPlugin(grok.GlobalUtility):
    93     """A plugin that updates courses.
    94     """
    95 
    96     grok.implements(IKofaPluggable)
    97     grok.name('courses')
    98 
    99     deprecated_attributes = []
    100 
    101     def setup(self, site, name, logger):
    102         return
    103 
    104     def update(self, site, name, logger):
    105         cat = getUtility(ICatalog, name='courses_catalog')
    106         results = cat.apply({'code':(None,None)})
    107         uidutil = getUtility(IIntIds, context=cat)
    108         items = getFields(ICourse).items()
    109         for r in results:
    110             o = uidutil.getObject(r)
    111             # Add new attributes
    112             for i in items:
    113                 if not hasattr(o,i[0]):
    114                     setattr(o,i[0],i[1].missing_value)
    115                     logger.info(
    116                         'CoursesPlugin: %s attribute %s added.' % (
    117                         o.code,i[0]))
    118             # Remove deprecated attributes
    119             for i in self.deprecated_attributes:
    120                 try:
    121                     delattr(o,i)
    122                     logger.info(
    123                         'CoursesPlugin: %s attribute %s deleted.' % (
    124                         o.code,i))
    125                 except AttributeError:
    126                     pass
    127         return
  • main/waeup.kofa/trunk/src/waeup/kofa/university/interfaces.py

    r9170 r9217  
    168168        )
    169169
    170     former_course = schema.Bool(
    171         title = _(u'Former Course'),
    172         description = _(
    173             u'If this attribute is being set all certificate courses '
    174             'referring to this course will be automatically deleted.'),
    175         required = False,
    176         default = False,
    177         )
    178 
    179170    def longtitle():
    180171        """
Note: See TracChangeset for help on using the changeset viewer.