Beispiel #1
0
def _qualifies_for_topics_only(obj):
    """
    Matches condition for adding pointers for topics seulement

    """
    site = obj.getSite()
    market_place = getattr(site, 'market-place')
    who_who = getattr(site, 'who-who')
    return ((isinstance(obj, NyContact) and
             (is_descendant_of(obj, market_place)
              or is_descendant_of(obj, who_who)))
            or (isinstance(obj, NyPublication)
                and is_descendant_of(obj, market_place)))
def _qualifies_for_topics_only(obj):
    """
    Matches condition for adding pointers for topics seulement

    """
    site = obj.getSite()
    market_place = getattr(site, 'market-place')
    who_who = getattr(site, 'who-who')
    return ((isinstance(obj, NyContact) and
             (is_descendant_of(obj, market_place) or
              is_descendant_of(obj, who_who))) or
            (isinstance(obj, NyPublication) and
             is_descendant_of(obj, market_place)))
Beispiel #3
0
def _qualifies_for_both(obj):
    """
    Matches condition for adding pointers for both topics and target_groups

    """
    site = obj.getSite()
    resources = site.resources
    news = site.News
    events = site.events
    who_who = getattr(site, 'who-who')
    return ((isinstance(obj, NyEvent) and is_descendant_of(obj, events)) or
        (isinstance(obj, NyNews) and is_descendant_of(obj, news)) or
        (isinstance(obj, (NyFile_extfile, NyBFile, NyMediaFile_extfile, NyURL, NyPublication))
          and is_descendant_of(obj, resources))
         or
        (isinstance(obj, (NyFile_extfile, NyBFile, NyMediaFile_extfile, NyURL, NyPublication, NyNews, NyEvent))
          and is_descendant_of(obj, who_who))
        )
Beispiel #4
0
def _qualifies_for_both(obj):
    """
    Matches condition for adding pointers for both topics and target_groups

    """
    site = obj.getSite()
    resources = site.resources
    news = site.News
    events = site.events
    who_who = getattr(site, 'who-who')
    return ((isinstance(obj, NyEvent) and is_descendant_of(obj, events))
            or (isinstance(obj, NyNews) and is_descendant_of(obj, news)) or
            (isinstance(obj,
                        (NyFile_extfile, NyBFile, NyMediaFile_extfile, NyURL,
                         NyPublication)) and is_descendant_of(obj, resources))
            or (isinstance(obj, (NyFile_extfile, NyBFile, NyMediaFile_extfile,
                                 NyURL, NyPublication, NyNews, NyEvent))
                and is_descendant_of(obj, who_who)))
    def _update(self, portal):
        countries_dir = portal['countries']
        topics_dir = portal['topics']
        who_dir = portal['who-who']
        resources_dir = portal['resources']
        market_place_dir = portal['market-place']
        events_dir = portal['events']
        news_dir = portal['News']
        cat = portal.getCatalogTool()
        pointers = map(lambda x: x.getObject(),
                  cat.search({'meta_type': 'Naaya Pointer',
                              'path': [ofs_path(countries_dir),
                                       ofs_path(topics_dir),
                                       ofs_path(who_dir)]}))
        count = 0
        for p in pointers:
            if not is_descendant_of(p, countries_dir):
                if len(p.getPhysicalPath()) <= 6:
                    #self.log.debug("Cleaning pointer: %s" % ofs_path(p))
                    count += 1
                    p.aq_parent._delObject(p.id)
            else:
                #self.log.debug("Cleaning pointer: %s" % ofs_path(p))
                count += 1
                p.aq_parent._delObject(p.id)
        self.log.debug("Cleaned %d pointers" % count)

        objects = []
        objects.extend(map(lambda x: x.getObject(),
                           cat.search({'meta_type': 'Naaya Event',
                                       'path': ofs_path(events_dir)})
                           ))
        objects.extend(map(lambda x: x.getObject(),
                           cat.search({'meta_type': 'Naaya News',
                                       'path': ofs_path(news_dir)})
                           ))
        objects.extend(map(lambda x: x.getObject(),
                           cat.search({'meta_type': ['Naaya File', 'Naaya Media File',
                                                     'Naaya URL', 'Naaya Publication'],
                                       'path': ofs_path(resources_dir)})
                           ))
        count = len(objects)
        for obj in objects:
            place_pointers(obj)
        objects = []
        objects.extend(map(lambda x: x.getObject(),
                           cat.search({'meta_type': 'Naaya Publication',
                                       'path': ofs_path(market_place_dir)})
                           ))
        objects.extend(map(lambda x: x.getObject(),
                           cat.search({'meta_type': 'Naaya Contact',
                                       'path': [ofs_path(market_place_dir),
                                                ofs_path(who_dir)]})
                           ))
        count += len(objects)
        for obj in objects:
            place_pointers(obj, exclude=['target-groups'])
        pointers = cat.search({'meta_type': 'Naaya Pointer',
                              'path': [ofs_path(countries_dir),
                                       ofs_path(topics_dir),
                                       ofs_path(who_dir)]})
        self.log.debug("Finished placing %d pointers for %d objects" %
                       (len(pointers), count))

        return True
Beispiel #6
0
    def _update(self, portal):
        countries_dir = portal['countries']
        topics_dir = portal['topics']
        who_dir = portal['who-who']
        resources_dir = portal['resources']
        market_place_dir = portal['market-place']
        events_dir = portal['events']
        news_dir = portal['News']
        cat = portal.getCatalogTool()
        pointers = map(
            lambda x: x.getObject(),
            cat.search({
                'meta_type':
                'Naaya Pointer',
                'path': [
                    ofs_path(countries_dir),
                    ofs_path(topics_dir),
                    ofs_path(who_dir)
                ]
            }))
        count = 0
        for p in pointers:
            if not is_descendant_of(p, countries_dir):
                if len(p.getPhysicalPath()) <= 6:
                    #self.log.debug("Cleaning pointer: %s" % ofs_path(p))
                    count += 1
                    p.aq_parent._delObject(p.id)
            else:
                #self.log.debug("Cleaning pointer: %s" % ofs_path(p))
                count += 1
                p.aq_parent._delObject(p.id)
        self.log.debug("Cleaned %d pointers" % count)

        objects = []
        objects.extend(
            map(
                lambda x: x.getObject(),
                cat.search({
                    'meta_type': 'Naaya Event',
                    'path': ofs_path(events_dir)
                })))
        objects.extend(
            map(
                lambda x: x.getObject(),
                cat.search({
                    'meta_type': 'Naaya News',
                    'path': ofs_path(news_dir)
                })))
        objects.extend(
            map(
                lambda x: x.getObject(),
                cat.search({
                    'meta_type': [
                        'Naaya File', 'Naaya Media File', 'Naaya URL',
                        'Naaya Publication'
                    ],
                    'path':
                    ofs_path(resources_dir)
                })))
        count = len(objects)
        for obj in objects:
            place_pointers(obj)
        objects = []
        objects.extend(
            map(
                lambda x: x.getObject(),
                cat.search({
                    'meta_type': 'Naaya Publication',
                    'path': ofs_path(market_place_dir)
                })))
        objects.extend(
            map(
                lambda x: x.getObject(),
                cat.search({
                    'meta_type':
                    'Naaya Contact',
                    'path': [ofs_path(market_place_dir),
                             ofs_path(who_dir)]
                })))
        count += len(objects)
        for obj in objects:
            place_pointers(obj, exclude=['target-groups'])
        pointers = cat.search({
            'meta_type':
            'Naaya Pointer',
            'path':
            [ofs_path(countries_dir),
             ofs_path(topics_dir),
             ofs_path(who_dir)]
        })
        self.log.debug("Finished placing %d pointers for %d objects" %
                       (len(pointers), count))

        return True