Beispiel #1
0
    def items(self):
        items = []

        if ISite.providedBy(self.context):
            return self._site_items
        elif IPage.providedBy(self.context):
            return self._page_items
        elif IServer.providedBy(self.context):
            return self._server_items
        elif INews.providedBy(self.context):
            return self._news_items
        return []
Beispiel #2
0
def evolve(context):
    """ Evolve
    """
    root = getRootFolder(context)
    site = root['stiam.ro']

    for page in site.values():
        if not IPage.providedBy(page):
            continue

        if hasattr(page, 'last_updated'):
            logger.info('Deleting last_updated attr: %s', page)
            delattr(page, 'last_updated')
        if hasattr(page, 'update_period'):
            logger.info('Deleting update_period attr: %s', page)
            delattr(page, 'update_period')
        if hasattr(page, 'sources'):
            logger.info('Deleting sources attr: %s', page)
            delattr(page, 'sources')
Beispiel #3
0
def evolve(context):
    """ Evolve
    """
    root = getRootFolder(context)
    site = root['stiam.ro']
    sm = site.getSiteManager()
    if 'cronjob4news' not in sm['default']:
        service = remotetask.TaskService()
        sm['default']['cronjob4news'] = service
        service = sm['default']['cronjob4news']
        sm.registerUtility(service, ITaskService, name="cronjob4news")
        logger.info('Registered utility cronjob4news')
    else:
        service = sm['default']['cronjob4news']

    # Add news updaters
    pages = site.values()

    sursa = site['sursa']
    now = datetime.now()
    minute = now.minute
    for page in pages:
        if not IPage.providedBy(page):
            continue

        sources = getattr(page, 'sources', '')
        if isinstance(sources, (str, unicode)):
            sources = sources.split('\n')

        for source in sources:
            server, news = source.split('/')
            rss = sursa[server][news]
            name = u'%s.%s.%s' % ('sursa', server, news)

            if 'updater' not in rss:
                logger.info('Adding updater for rss %s', name)
                updater = NewsUpdater()
                rss['updater'] = updater
                updater = rss['updater']
                sm.registerUtility(updater, ITask, name=name)
                service.addCronJob(name, (), minute=(minute,))
                minute += 7
                minute = minute % 60
Beispiel #4
0
 def __init__(self, context, request, view, manager):
     super(HeadViewlet, self).__init__(context, request, view, manager)
     self.page = self.context
     while IPage.providedBy(self.context):
         self.context = self.context.__parent__
Beispiel #5
0
 def __init__(self, context, request, view, manager):
     super(HeaderViewlet, self).__init__(context, request, view, manager)
     if not IPage.providedBy(self.context):
         self.context = self.homepage