Exemple #1
0
def evolve(context):
    linkcatalogs.ensureEvolved(context)
    root = context.connection.root().get(ZopePublication.root_name, None)

    savepoint_counter = 0

    # Groups are no longer allowed as members of a section.
    groups = findObjectsProviding(root, IGroup)
    for group in groups:
        targets = getRelatedObjects(group, URIGroup, rel_type=URIMembership)
        group_members = getRelatedObjects(group,
                                          URIMember,
                                          rel_type=URIMembership)

        for target in targets:
            target_members = getRelatedObjects(target,
                                               URIMember,
                                               rel_type=URIMembership)
            for member in group_members:
                if member not in target_members:
                    relate(URIMembership, (member, URIMember),
                           (target, URIGroup))
                savepoint_counter += 1
            unrelate(URIMembership, (group, URIMember), (target, URIGroup))
        if savepoint_counter % 2000 == 0:
            transaction.savepoint(optimistic=True)

    # Courses gained several new attributes, fill in their course_id
    courses = findObjectsProviding(root, ICourse)
    for course in courses:
        if getattr(course, 'course_id', None) is None:
            course.course_id = course.__name__
def evolve(context):
    linkcatalogs.ensureEvolved(context)
    root = context.connection.root().get(ZopePublication.root_name, None)

    savepoint_counter = 0

    # Groups are no longer allowed as members of a section.
    groups = findObjectsProviding(root, IGroup)
    for group in groups:
        targets = getRelatedObjects(
            group, URIGroup, rel_type=URIMembership)
        group_members = getRelatedObjects(
            group, URIMember, rel_type=URIMembership)

        for target in targets:
            target_members = getRelatedObjects(
                target, URIMember, rel_type=URIMembership)
            for member in group_members:
                if member not in target_members:
                    relate(URIMembership,
                           (member, URIMember),
                           (target, URIGroup))
                savepoint_counter += 1
            unrelate(URIMembership,
                     (group, URIMember),
                     (target, URIGroup))
        if savepoint_counter % 2000 == 0:
            transaction.savepoint(optimistic=True)

    # Courses gained several new attributes, fill in their course_id
    courses = findObjectsProviding(root, ICourse)
    for course in courses:
        if getattr(course, 'course_id', None) is None:
            course.course_id = course.__name__
Exemple #3
0
 def sections(self):
     return getRelatedObjects(self.person,
                              URISection,
                              rel_type=URIInstruction)
Exemple #4
0
 def _getSections(self, ob):
     return [
         section for section in getRelatedObjects(ob, membership.URIGroup)
         if interfaces.ISection.providedBy(section)
     ]
 def sections(self):
     return getRelatedObjects(self.person, URISection,
                              rel_type=URIInstruction)
 def _getSections(self, ob):
     return [section for section in getRelatedObjects(ob, membership.URIGroup)
             if interfaces.ISection.providedBy(section)]