Esempio n. 1
0
    def test_get_occurrences(self):
        brains = get_portal_events(self.portal)

        result = get_occurrences_from_brains(self.portal, brains)
        self.assertTrue(len(result) == 9)

        result = get_occurrences_from_brains(self.portal, brains,
                range_start=self.now)
        self.assertTrue(len(result) == 9)

        result = get_occurrences_from_brains(self.portal, brains, limit=5)
        self.assertTrue(len(result) == 5)
        self.assertTrue(IEventAccessor.providedBy(result[0]))
Esempio n. 2
0
 def get_data(self):
     start = guess_date_from(self.request.form.get('start', ''))
     limit = self.request.form.get('limit', None)
     b_size = self.request.form.get('b_size', 20)
     b_start = self.request.form.get('b_start', 0)
     result = get_portal_events(self.context, range_start=start)
     # TODO: performance issue! the batch is somehow useless, if we
     # calculate every result item anyways.
     occ = [IEventAccessor(occ) for occ in\
            get_occurrences_from_brains(self.context,
                                        result,
                                        range_start=start,
                                        limit=limit)]
     return Batch(occ, b_size, b_start)
Esempio n. 3
0
    def get_events(self, start=None, end=None, batch=True, mode=None):
        context = self.context

        mode = mode or self.mode
        if not mode and not start and not end:
            mode = "future"
        if mode:
            dt = None
            if self.date:
                try:
                    dt = guess_date_from(self.date)
                except TypeError:
                    pass
            start, end = start_end_from_mode(mode, dt, context)

        b_start = b_size = None
        if batch:
            b_start = self.b_start
            b_size = self.b_size

        occs = get_occurrences_from_brains(
            context,
            get_portal_events(
                context,
                start,
                end,
                # b_start=b_start, b_size=b_size,
                path=context.getPhysicalPath(),
            ),
            start,
            end,
        )

        if batch:
            ret = Batch(occs, size=b_size, start=b_start, orphan=self.orphan)
        else:
            ret = occs

        return ret
 def published_events(self):
     context = aq_inner(self.context)
     return get_occurrences_from_brains(context, self._data(),
             range_start=localized_now(), limit=self.data.count)
 def test_get_occurrences(self):
     get_occurrences_from_brains(object, [],
             range_start=datetime.datetime.today())