def add_course_portlet(obj, event): # Only do this if the parent is not a course, i.e. only do it on # top-level course. Of course, site managers can move things # around once the site structure is created parent = aq_parent(aq_inner(obj)) if ICourse.providedBy(parent): return # A portlet manager is akin to a column column = getUtility(IPortletManager, name=COURSEBOX_PORTLET_COLUMN) # We multi-adapt the object and the column to an assignment mapping, # which acts like a dict where we can put portlet assignments manager = getMultiAdapter(( obj, column, ), IPortletAssignmentMapping) # We then create the assignment and put it in the assignment manager, # using the default name-chooser to pick a suitable name for us. assignment = coursebox.Assignment() chooser = INameChooser(manager) manager[chooser.chooseName(None, assignment)] = assignment
def add_course_portlet(obj, event): # Only do this if the parent is not a course, i.e. only do it on # top-level course. Of course, site managers can move things # around once the site structure is created parent = aq_parent(aq_inner(obj)) if ICourse.providedBy(parent): return # A portlet manager is akin to a column column = getUtility(IPortletManager, name=COURSEBOX_PORTLET_COLUMN) # We multi-adapt the object and the column to an assignment mapping, # which acts like a dict where we can put portlet assignments manager = getMultiAdapter((obj, column), IPortletAssignmentMapping) # We then create the assignment and put it in the assignment manager, # using the default name-chooser to pick a suitable name for us. assignment = coursebox.Assignment() chooser = INameChooser(manager) manager[chooser.chooseName(None, assignment)] = assignment
def courseURL(self): context = aq_inner(self.context) while not ICourse.providedBy(context): context = aq_parent(aq_inner(context)) return context.absolute_url()