当前位置: 首页>>代码示例>>Python>>正文


Python IOccurrence.providedBy方法代码示例

本文整理汇总了Python中plone.event.interfaces.IOccurrence.providedBy方法的典型用法代码示例。如果您正苦于以下问题:Python IOccurrence.providedBy方法的具体用法?Python IOccurrence.providedBy怎么用?Python IOccurrence.providedBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plone.event.interfaces.IOccurrence的用法示例。


在下文中一共展示了IOccurrence.providedBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_generation_context

# 需要导入模块: from plone.event.interfaces import IOccurrence [as 别名]
# 或者: from plone.event.interfaces.IOccurrence import providedBy [as 别名]
 def _get_generation_context(self, helper_view, pod_template):
     result = super(IDocumentGenerationView, self)._get_generation_context(
         helper_view, pod_template)
     # if pod_template.portal_type == 'ConfigurablePODTemplate':
     if IFacetedNavigable.providedBy(self.context):
         brains = getDashboardQueryResult(self.context)
         result['brains'] = brains
         if len(brains) > 0 and brains[0].portal_type == 'Event':
             expandevents = expand_events(brains, 2)
             events = []
             for event in expandevents:
                 if IOccurrence.providedBy(event):
                     start = event.start
                     end = event.end
                     parent = zope.copy.copy(event.aq_parent.aq_base)
                     parent.start = start
                     parent.end = end
                     req = event.REQUEST
                     parent.REQUEST = req
                     parent.occurrence = True
                     parent.base_event = event.aq_parent
                     events.append(parent)
                 else:
                     events.append(event)
             result['brains'] = events
         return result
开发者ID:IMIO,项目名称:cpskin.core,代码行数:28,代码来源:pages.py

示例2: ticket_title_generator

# 需要导入模块: from plone.event.interfaces import IOccurrence [as 别名]
# 或者: from plone.event.interfaces.IOccurrence import providedBy [as 别名]
def ticket_title_generator(obj):
    """Generate a title for the ticket, also using event information.
    """

    event = obj
    ret = {
        'title': obj.title, 'eventtitle': '', 'eventstart': '', 'eventend': ''
    }

    if ITicketOccurrence.providedBy(event):
        event = aq_parent(aq_parent(event))
        # Traverse to the Occurrence object
        if IATEvent.providedBy(event):
            # get the request out of thin air to be able to publishTraverse to
            # the transient Occurrence object.
            traverser = OccTravAT(event, getRequest())
        elif IDXEvent.providedBy(event):
            # TODO
            traverser = OccTravDX(event, getRequest())
        else:
            raise NotImplementedError(
                u"There is no event occurrence traverser implementation for "
                u"this kind of object."
            )
        try:
            event = traverser.publishTraverse(getRequest(), obj.id)
        except KeyError:
            # Maybe the ticket occurrence isn't valid anymore because the
            # event occurence doesn't exist anymore.
            # Just ignore that case.
            return ret

    elif ITicket.providedBy(event):
        event = aq_parent(event)

    if IEvent.providedBy(event) or IOccurrence.providedBy(event):
        acc = IEventAccessor(event)
        lstart = ulocalized_time(
            DT(acc.start),
            long_format=True,
            context=event
        )
        lend = ulocalized_time(
            DT(acc.start),
            long_format=True,
            context=event
        )
        # XXX: no unicode, store as utf-8 encoded string instead
        ret = dict(
            title=u'%s - %s (%s - %s)' % (
                safe_unicode(acc.title),
                safe_unicode(obj.title),
                lstart,
                lend,
            ),
            eventtitle=acc.title,
            eventstart=acc.start,
            eventend=acc.end,
        )
    return ret
开发者ID:bluedynamics,项目名称:bda.plone.ticketshop,代码行数:62,代码来源:common.py

示例3: test_recurrence_occurrences_with_range_start_2

# 需要导入模块: from plone.event.interfaces import IOccurrence [as 别名]
# 或者: from plone.event.interfaces.IOccurrence import providedBy [as 别名]
    def test_recurrence_occurrences_with_range_start_2(self):
        # Test with range
        rs = datetime.datetime(2011, 11, 16, 11, 0, tzinfo=self.tz)
        result = IRecurrenceSupport(self.data).occurrences(range_start=rs)

        self.assertEqual(3, len(result))

        # Only IOccurrence objects in the result set
        self.assertTrue(IOccurrence.providedBy(result[0]))
开发者ID:FHNW,项目名称:plone.app.event,代码行数:11,代码来源:test_recurrence.py

示例4: test_recurrence_occurrences

# 需要导入模块: from plone.event.interfaces import IOccurrence [as 别名]
# 或者: from plone.event.interfaces.IOccurrence import providedBy [as 别名]
    def test_recurrence_occurrences(self):
        result = IRecurrenceSupport(self.data).occurrences()

        self.assertEqual(4, len(result))

        # First occurrence is an IEvent object
        self.assertTrue(IEvent.providedBy(result[0]))

        # Subsequent ones are IOccurrence objects
        self.assertTrue(IOccurrence.providedBy(result[1]))
开发者ID:FHNW,项目名称:plone.app.event,代码行数:12,代码来源:test_recurrence.py

示例5: test_recurrence_occurrences_with_range_start_1

# 需要导入模块: from plone.event.interfaces import IOccurrence [as 别名]
# 或者: from plone.event.interfaces.IOccurrence import providedBy [as 别名]
    def test_recurrence_occurrences_with_range_start_1(self):
        # Test with range
        rs = datetime.datetime(2011, 11, 15, 11, 0, tzinfo=self.tz)
        result = IRecurrenceSupport(self.data).occurrences(range_start=rs)

        self.assertEqual(4, len(result))

        # First occurrence is an IEvent object
        self.assertTrue(IEvent.providedBy(result[0]))

        # Subsequent ones are IOccurrence objects
        self.assertTrue(IOccurrence.providedBy(result[1]))
开发者ID:FHNW,项目名称:plone.app.event,代码行数:14,代码来源:test_recurrence.py

示例6: childsiteForContext

# 需要导入模块: from plone.event.interfaces import IOccurrence [as 别名]
# 或者: from plone.event.interfaces.IOccurrence import providedBy [as 别名]
 def childsiteForContext(self, item):
     """Returns the childsite UUID for a context object by looking up it's
     brain in the catalog.
     """
     childsite = ''
     if IOccurrence and IOccurrence.providedBy(item):
         item = aq_parent(item)
     portal = plone.api.portal.get()
     cat = getToolByName(self.context, 'portal_catalog')
     res = cat(UID=IUUID(item, None), path=portal.getPhysicalPath())
     if res:
         childsite = res[0].childsite
     return childsite
开发者ID:collective,项目名称:lineage.index,代码行数:15,代码来源:view.py

示例7: test_occurrence

# 需要导入模块: from plone.event.interfaces import IOccurrence [as 别名]
# 或者: from plone.event.interfaces.IOccurrence import providedBy [as 别名]
    def test_occurrence(self):
        # start date of self.now_event = 2013-05-05, 10:00.
        # recurrence rule = 'RRULE:FREQ=DAILY;COUNT=3;INTERVAL=2'

        # Try to traverse to inexistent occurrence
        self.assertRaises(
            AttributeError,
            self.traverser.publishTraverse,
            self.request, '2000-01-01')

        # Traverse to existent occurrence
        item = self.traverser.publishTraverse(self.request, '2013-05-07')
        self.assertTrue(IOccurrence.providedBy(item))
        self.assertEqual(type(self.now_event), type(item.aq_parent))
开发者ID:FHNW,项目名称:plone.app.event,代码行数:16,代码来源:test_recurrence.py

示例8: test_occurrence

# 需要导入模块: from plone.event.interfaces import IOccurrence [as 别名]
# 或者: from plone.event.interfaces.IOccurrence import providedBy [as 别名]
    def test_occurrence(self):
        self.at.setRecurrence('RRULE:FREQ=WEEKLY;COUNT=10')

        # does not match occurrence date
        qdate = datetime.date.today() + datetime.timedelta(days=4)
        self.assertRaises(
            AttributeError,
            self.at_traverser.publishTraverse,
            self.layer['request'], str(qdate))

        qdatedt = pydt(self.at.start() + 7)
        item = self.at_traverser.publishTraverse(self.layer['request'],
                                                 str(qdatedt.date()))
        self.assertTrue(IOccurrence.providedBy(item))
        self.assertTrue(IATEvent.providedBy(item.aq_parent))
开发者ID:senner,项目名称:plone.app.event,代码行数:17,代码来源:test_recurrence.py

示例9: test_recurrence_occurrences_with_range_start_and_end

# 需要导入模块: from plone.event.interfaces import IOccurrence [as 别名]
# 或者: from plone.event.interfaces.IOccurrence import providedBy [as 别名]
    def test_recurrence_occurrences_with_range_start_and_end(self):
        # Test with range
        rs = datetime.datetime(2011, 11, 11, 11, 0, tzinfo=self.tz)
        re = datetime.datetime(2011, 11, 12, 11, 0, tzinfo=self.tz)
        result = IRecurrenceSupport(self.data).occurrences(range_start=rs,
                                                           range_end=re)
        result = list(result)  # cast generator to list

        self.assertEqual(2, len(result))

        # First occurrence is an IEvent object
        self.assertTrue(IEvent.providedBy(result[0]))

        # Subsequent ones are IOccurrence objects
        self.assertTrue(IOccurrence.providedBy(result[1]))
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:17,代码来源:test_recurrence.py

示例10: test_recurrence

# 需要导入模块: from plone.event.interfaces import IOccurrence [as 别名]
# 或者: from plone.event.interfaces.IOccurrence import providedBy [as 别名]
    def test_recurrence(self):
        tz = pytz.timezone('Europe/Vienna')
        duration = datetime.timedelta(days=4)
        data = MockEvent()
        data.start = datetime.datetime(2011, 11, 11, 11, 00, tzinfo=tz)
        data.end = data.start + duration
        data.recurrence = 'RRULE:FREQ=DAILY;COUNT=4'
        zope.interface.alsoProvides(data, IEvent, IEventRecurrence)
        result = IRecurrenceSupport(data).occurrences()

        self.assertEqual(4, len(result))

        # First occurrence is an IEvent object
        self.assertTrue(IEvent.providedBy(result[0]))

        # Subsequent ones are IOccurrence objects
        self.assertTrue(IOccurrence.providedBy(result[1]))
开发者ID:senner,项目名称:plone.app.event,代码行数:19,代码来源:test_recurrence.py

示例11: test_recurrence

# 需要导入模块: from plone.event.interfaces import IOccurrence [as 别名]
# 或者: from plone.event.interfaces.IOccurrence import providedBy [as 别名]
    def test_recurrence(self):
        tz = pytz.timezone('Europe/Vienna')
        duration = timedelta(days=4)
        mock = MockEvent()
        mock.start = tz.localize(datetime(2011, 11, 11, 11, 0))
        mock.end = mock.start + duration
        mock.recurrence = 'RRULE:FREQ=DAILY;COUNT=4'
        zope.interface.alsoProvides(
            mock, IEvent, IEventBasic, IEventRecurrence,
            IDXEvent, IDXEventRecurrence)
        result = IRecurrenceSupport(mock).occurrences()
        result = list(result)  # cast generator to list

        self.assertEqual(4, len(result))

        # First occurrence is an IEvent object
        self.assertTrue(IEvent.providedBy(result[0]))

        # Subsequent ones are IOccurrence objects
        self.assertTrue(IOccurrence.providedBy(result[1]))
开发者ID:plone,项目名称:plone.app.event,代码行数:22,代码来源:test_dx_behaviors.py

示例12: attachments

# 需要导入模块: from plone.event.interfaces import IOccurrence [as 别名]
# 或者: from plone.event.interfaces.IOccurrence import providedBy [as 别名]
 def attachments(self):
     context = aq_inner(self.context)
     if IOccurrence.providedBy(context):
         # support for related images on event occurrences
         context = context.aq_parent
     atts = IRelatedMedia(context).related_attachments
     _target_blank = api.portal.get_registry_record(
         'collective.behavior.relatedmedia.open_attachment_in_new_window')
     link_target = _target_blank and 'blank' or 'top'
     for att in atts:
         att_obj = att.to_object
         if att_obj:
             yield dict(
                 url=att_obj.absolute_url(),
                 title=att_obj.Title(),
                 size="{:.1f} MB".format(
                     att_obj.file.getSize() / 1024.0 / 1024.0),
                 icon=att_obj.getIcon(),
                 target=link_target,
             )
开发者ID:kombinat,项目名称:collective.behavior.relatedmedia,代码行数:22,代码来源:browser.py

示例13: test_occurrence

# 需要导入模块: from plone.event.interfaces import IOccurrence [as 别名]
# 或者: from plone.event.interfaces.IOccurrence import providedBy [as 别名]
    def test_occurrence(self):
        # start date of self.now_event = 2013-05-05, 10:00.
        # recurrence rule = 'RRULE:FREQ=DAILY;COUNT=3;INTERVAL=2'

        # Try to traverse to inexistent occurrence
        self.assertRaises(
            AttributeError,
            self.traverser.publishTraverse,
            self.request, '2000-01-01')

        # Traverse to existent occurrence
        item = self.traverser.publishTraverse(self.request, '2013-05-07')
        self.assertTrue(IOccurrence.providedBy(item))
        self.assertEqual(type(self.now_event), type(item.aq_parent))

        # Test attributes of Occurrence
        self.assertEqual(item.portal_type, 'Occurrence')
        self.assertEqual(item.id, '2013-05-07')
        delta = datetime.timedelta(days=2)
        self.assertEqual(item.start, self.now + delta)
        self.assertEqual(item.end, self.now + delta + self.duration)
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:23,代码来源:test_recurrence.py

示例14: recurrence

# 需要导入模块: from plone.event.interfaces import IOccurrence [as 别名]
# 或者: from plone.event.interfaces.IOccurrence import providedBy [as 别名]
    def recurrence(self):
        if not self.event.recurrence or IOccurrence.providedBy(self.context):
            return None

        ret = []
        for recdef in self.event.recurrence.split():
            prop, val = recdef.split(':')
            if prop == 'RRULE':
                ret.append({
                    'property': prop,
                    'value': icalendar.prop.vRecur.from_ical(val)
                })

            elif prop in ('EXDATE', 'RDATE'):
                factory = icalendar.prop.vDDDLists

                # localize ex/rdate
                # TODO: should better already be localized by event object
                tzid = self.event.timezone
                if isinstance(tzid, tuple):
                    tzid = tzid[0]
                # get list of datetime values from ical string
                try:
                    dtlist = factory.from_ical(val, timezone=tzid)
                except ValueError:
                    # TODO: caused by a bug in plone.formwidget.recurrence,
                    # where the recurrencewidget or plone.event fails with
                    # COUNT=1 and a extra RDATE.
                    # TODO: REMOVE this workaround, once this failure is
                    # fixed in recurrence widget.
                    continue
                ret.append({
                    'property': prop,
                    'value': dtlist
                })

        return ret
开发者ID:plone,项目名称:plone.app.event,代码行数:39,代码来源:exporter.py

示例15: is_occurrence

# 需要导入模块: from plone.event.interfaces import IOccurrence [as 别名]
# 或者: from plone.event.interfaces.IOccurrence import providedBy [as 别名]
 def is_occurrence(self):
     return IOccurrence.providedBy(self.context)
开发者ID:saily,项目名称:plone.app.event,代码行数:4,代码来源:event_summary.py


注:本文中的plone.event.interfaces.IOccurrence.providedBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。