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


Python interfaces.IEvent类代码示例

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


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

示例1: timezone_handler

def timezone_handler(obj, event):
    """ When setting the startDate and endDate, the value of the timezone field
    isn't known, so we have to convert those timezone-naive dates into
    timezone-aware ones afterwards.

    """

    if not IEvent.providedBy(obj):
        # don't run me, if i'm not installed
        return

    timezone = obj.getField('timezone').get(obj)
    start_field = obj.getField('startDate')
    end_field = obj.getField('endDate')
    start = start_field.get(obj)
    end = end_field.get(obj)

    def make_DT(value, timezone):
        return DateTime(
            value.year(),
            value.month(),
            value.day(),
            value.hour(),
            value.minute(),
            value.second(),
            timezone)

    start = make_DT(start, timezone).toZone('UTC')
    end = make_DT(end, timezone).toZone('UTC')
    start_field.set(obj, start)
    end_field.set(obj, end)
    obj.reindexObject()
开发者ID:mooballit,项目名称:plone.app.event,代码行数:32,代码来源:content.py

示例2: EventTypes

def EventTypes(context):
    """ Vocabulary for available event types.

    Insane stuff: All types are created temporary and checked if the provide
    the IEvent interface. At least, this function is cached forever the Zope
    process lives.
    """
    # TODO: I'd love to query the factory for types, who's instances are
    # implementing a specific interface via the portal_factory API.

    portal = getSite()
    tmp_folder_id = 'event_types_temp_folder__%s' % random.randint(0, 99999999)
    portal.invokeFactory('Folder', tmp_folder_id)
    try:
        tmp_folder = portal._getOb(tmp_folder_id)
        portal_types = getToolByName(portal, 'portal_types')
        all_types = portal_types.listTypeInfo(portal)
        event_types = []
        cnt = 0
        for fti in all_types:
            if not getattr(fti, 'global_allow', False):
                continue
            cnt += 1
            tmp_id = 'temporary__event_types__%s' % cnt
            tmp_obj = None
            fti.constructInstance(tmp_folder, tmp_id)
            tmp_obj = tmp_folder._getOb(tmp_id)
            if tmp_obj:
                if IEvent.providedBy(tmp_obj):
                    event_types.append(fti.id)
    finally:
        # Delete the tmp_folder again
        tmp_folder.__parent__.manage_delObjects([tmp_folder_id])

    return SimpleVocabulary.fromValues(event_types)
开发者ID:borinot,项目名称:plone.app.event,代码行数:35,代码来源:vocabularies.py

示例3: ticket_title_generator

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,代码行数:60,代码来源:common.py

示例4: test_fix_interface_for_event

    def test_fix_interface_for_event(self):
        self.obj.portal_type = 'Event'
        self.catalog.reindexObject(self.obj)

        self.portal.restrictedTraverse('fix_base_classes')()

        self.assertTrue(IEvent.providedBy(self.obj))
开发者ID:enfold,项目名称:plone.app.contenttypes,代码行数:7,代码来源:test_migration_browser.py

示例5: test_upgrade_step_1

    def test_upgrade_step_1(self):
        _dummy_1 = mkDummyInContext(MockATEvent_1, oid='dummy_1',
                                    context=self.portal,
                                    schema=ATContentTypeSchema)
        _dummy_1.title = 'Foo'
        _dummy_1.reindexObject()

        event = self.portal['dummy_1']
        self.assertTrue(not IEvent.providedBy(event))
        del event

        upgrade_step_1(self.portal)

        event = self.portal['dummy_1']
        self.assertTrue(IEvent.providedBy(event))
        self.assertEqual('', event.recurrence)
        self.assertEqual('Foo', event.Title())
开发者ID:FHNW,项目名称:plone.app.event,代码行数:17,代码来源:test_upgrades.py

示例6: _allDay

 def _allDay(self):
     if HAS_PAE:
         if IEvent.providedBy(self.context):
             acc = IEventAccessor(self.context)
             return acc.whole_day or False
     if self._all_day is not None:
         return bool(self._all_day)
     return False
开发者ID:kingel,项目名称:Solgema.fullcalendar,代码行数:8,代码来源:content.py

示例7: test_factory

 def test_factory(self):
     fti = queryUtility(
         IDexterityFTI,
         name='Event'
     )
     factory = fti.factory
     new_object = createObject(factory)
     self.assertTrue(IEvent.providedBy(new_object))
开发者ID:enfold,项目名称:plone.app.contenttypes,代码行数:8,代码来源:test_event.py

示例8: set_allDay

 def set_allDay(self, v):
     v = bool(v)
     if HAS_PAE:
         if IEvent.providedBy(self.context):
             acc = IEventAccessor(self.context)
             acc.whole_day = v
             return
     self._all_day = v
开发者ID:kingel,项目名称:Solgema.fullcalendar,代码行数:8,代码来源:content.py

示例9: data_postprocessing

def data_postprocessing(obj, event):
    """When setting the startDate and endDate, the value of the timezone field
    isn't known, so we have to convert those timezone-naive dates into
    timezone-aware ones afterwards.

    For whole day events, set start time to 0:00:00 and end time toZone
    23:59:59.

    """

    if not IEvent.providedBy(obj):
        # don't run me, if i'm not installed
        return

    timezone = obj.getField('timezone').get(obj)
    start_field = obj.getField('startDate')
    end_field = obj.getField('endDate')

    # The previous_timezone is set, when the timezone has changed to another
    # value. In this case we need to convert the UTC dt values to the
    # previous_timezone, so that we get the datetime values, as the user
    # entered them. However, this value might be always set, even when creating
    # an event, since ObjectModifiedEvent is called several times when editing.
    prev_tz = getattr(obj, 'previous_timezone', None)
    if prev_tz: delattr(obj, 'previous_timezone')

    def _fix_zone(dt, tz):
        if not dt.timezoneNaive():
            # The object is edited and the value alreadty stored in UTC on the
            # object. In this case we want the value converted to the given
            # timezone, in which the user entered the data.
            dt = dt.toZone(tz)
        return dt

    start = _fix_zone(start_field.get(obj), prev_tz and prev_tz or timezone)
    end = _fix_zone(end_field.get(obj), prev_tz and prev_tz or timezone)

    def make_DT(value, timezone):
        return DateTime(
            value.year(),
            value.month(),
            value.day(),
            value.hour(),
            value.minute(),
            value.second(),
            timezone)

    start = make_DT(start, timezone)
    end = make_DT(end, timezone)

    if obj.getWholeDay():
        start = DateTime('%s 0:00:00 %s' % (start.Date(), timezone))
        end = DateTime('%s 23:59:59 %s' % (end.Date(), timezone))

    start_field.set(obj, start.toZone('UTC'))
    end_field.set(obj, end.toZone('UTC'))
    obj.reindexObject()
开发者ID:senner,项目名称:plone.app.event,代码行数:57,代码来源:content.py

示例10: test_recurrence_occurrences

    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,代码行数:10,代码来源:test_recurrence.py

示例11: test_implementsInterfaces

    def test_implementsInterfaces(self):
        """Test if an ATEvent object implements all relevant interfaces.

        """
        self.assertTrue(IEvent.providedBy(self.obj))
        self.assertTrue(IEventRecurrence.providedBy(self.obj))
        self.assertTrue(IATEvent.providedBy(self.obj))
        self.assertTrue(IATEventRecurrence.providedBy(self.obj))

        self.assertTrue(IATEvent_ATCT.providedBy(self.obj))
        self.assertTrue(verifyObject(IATEvent_ATCT, self.obj))
开发者ID:mooballit,项目名称:plone.app.event,代码行数:11,代码来源:test_atevent.py

示例12: _get_event_url

def _get_event_url(ticket):
    """Return the URL to an event or event occurrence for a ticket or ticket
    occurrence.
    """

    url = ticket.absolute_url()

    if ITicketOccurrence.providedBy(ticket):
        # assumption1: ticketoccurrence id = occurrence id
        # assumption2: ticketoccurrence parent = ticket
        event = aq_parent(aq_parent(ticket))
        if IEvent.providedBy(event):
            url = "{}/{}".format(event.absolute_url(), ticket.id)

    elif ITicket.providedBy(ticket):
        event = aq_parent(ticket)
        if IEvent.providedBy(event):
            url = event.absolute_url()

    return url
开发者ID:bluedynamics,项目名称:bda.plone.ticketshop,代码行数:20,代码来源:views.py

示例13: test_recurrence_occurrences_with_range_start_1

    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,代码行数:12,代码来源:test_recurrence.py

示例14: expand_events

def expand_events(events, ret_mode,
                  start=None, end=None,
                  sort=None, sort_reverse=None):
    """Expand to the recurrence occurrences of a given set of events.

    :param events: IEvent based objects or IEventAccessor object wrapper.

    :param ret_mode: Return type of search results. These options are
                     available:

                         * 2 (objects): Return results as IEvent and/or
                                        IOccurrence objects.
                         * 3 (accessors): Return results as IEventAccessor
                                          wrapper objects.
                     Option "1" (brains) is not supported.

    :type ret_mode: integer [2|3]

    :param start: Date, from which on events should be expanded.
    :type start: Python datetime.

    :param end: Date, until which events should be expanded.
    :type end: Python datetime

    :param sort: Object or IEventAccessor Attribute to sort on.
    :type sort: string

    :param sort_reverse: Change the order of the sorting.
    :type sort_reverse: boolean
    """
    assert(ret_mode is not RET_MODE_BRAINS)

    exp_result = []
    for it in events:
        obj = it.getObject() if getattr(it, 'getObject', False) else it
        if IEventRecurrence.providedBy(obj):
            occurrences = [_obj_or_acc(occ, ret_mode) for occ in
                           IRecurrenceSupport(obj).occurrences(start, end)]
        elif IEvent.providedBy(obj):
            occurrences = [_obj_or_acc(obj, ret_mode)]
        else:
            # No IEvent based object. Could come from a collection.
            continue
        exp_result += occurrences
    if sort:
        exp_result.sort(key=lambda x: _get_compare_attr(x, sort))
    if sort_reverse:
        exp_result.reverse()
    return exp_result
开发者ID:plone,项目名称:plone.app.event,代码行数:49,代码来源:base.py

示例15: test_recurrence_occurrences_with_range_start_and_end

    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,代码行数:15,代码来源:test_recurrence.py


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