本文整理汇总了Python中plone.event.interfaces.IEventAccessor.edit方法的典型用法代码示例。如果您正苦于以下问题:Python IEventAccessor.edit方法的具体用法?Python IEventAccessor.edit怎么用?Python IEventAccessor.edit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plone.event.interfaces.IEventAccessor
的用法示例。
在下文中一共展示了IEventAccessor.edit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from plone.event.interfaces import IEventAccessor [as 别名]
# 或者: from plone.event.interfaces.IEventAccessor import edit [as 别名]
def create(
cls,
container,
content_id,
title,
description=None,
start=None,
end=None,
timezone=None,
whole_day=None,
open_end=None,
**kwargs
):
container.invokeFactory(
cls.event_type,
id=content_id,
title=title,
description=description,
startDate=start,
endDate=end,
wholeDay=whole_day,
open_end=open_end,
timezone=timezone,
)
content = container[content_id]
acc = IEventAccessor(content)
acc.edit(**kwargs)
return acc
示例2: updateObject
# 需要导入模块: from plone.event.interfaces import IEventAccessor [as 别名]
# 或者: from plone.event.interfaces.IEventAccessor import edit [as 别名]
def updateObject(self, context, v):
# Get the accessor object
acc = IEventAccessor(context)
# Establish the input arguments
kwargs = self.getRequestDataAsArguments(v)
# Pass the arguments into the object
acc.edit(**kwargs)
# Update any arguments that are not part of the default event schema
acc.update(**kwargs)
# Update complex fields (text, event agenda)
self.updateComplexFields(acc.context, v)
# Reindex the object
acc.context.reindexObject()
# Ref: http://docs.plone.org/external/plone.app.event/docs/development.html#accessing-event-objects-via-an-unified-accessor-object
# Throw ObjectModifiedEvent after setting properties to call an event subscriber which does some timezone related post calculations
notify(ObjectModifiedEvent(acc.context))
# Return object that was updated
return acc.context
示例3: importContent
# 需要导入模块: from plone.event.interfaces import IEventAccessor [as 别名]
# 或者: from plone.event.interfaces.IEventAccessor import edit [as 别名]
def importContent(self):
# Create new content importer object
v = AtlasProductImporter(uid=self.uid, domain=self.domain)
# Additional fields
kwargs = {}
# Add a Webinar Group
webinar_group = self.addWebinarGroup(self.import_path, v, **kwargs)
# Add the Webinar
webinar = self.addWebinar(webinar_group, v,
**kwargs)
# Set the webinar start/end dates to publish date of imported object
webinar_date_start = v.data.start
webinar_date_start = DateTime(webinar_date_start).asdatetime()
webinar_date_end = v.data.end
webinar_date_end = DateTime(webinar_date_end).asdatetime()
acc = IEventAccessor(webinar)
acc.edit(start=webinar_date_start, end=webinar_date_end)
acc.update(start=webinar_date_start, end=webinar_date_end)
# Initialize webinar_url variable
webinar_url = v.data.event_url
# If we have a 'webinar_url', set that on the Webinar Product
if webinar_url:
acc.edit(webinar_url=webinar_url)
acc.update(webinar_url=webinar_url)
# Finalize items
self.finalize(webinar)
self.finalize(webinar_group)
# Return JSON output
return self.getJSON(webinar_group)
示例4: test_event_accessor
# 需要导入模块: from plone.event.interfaces import IEventAccessor [as 别名]
# 或者: from plone.event.interfaces.IEventAccessor import edit [as 别名]
def test_event_accessor(self):
utc = pytz.utc
vienna = pytz.timezone('Europe/Vienna')
self.portal.invokeFactory('Event', 'event1',
description='a description',
startDate=datetime(2011, 11, 11, 11, 0, tzinfo=utc),
endDate=datetime(2011, 11, 11, 12, 0, tzinfo=utc),
timezone='UTC',
wholeDay=False)
e1 = self.portal['event1']
acc = IEventAccessor(e1)
# TEST DATES
self.assertEqual(acc.start, datetime(2011, 11, 11, 11, 0, tzinfo=utc))
self.assertEqual(acc.end, datetime(2011, 11, 11, 12, 0, tzinfo=utc))
acc.start = datetime(2011, 11, 13, 9, 0) # tzinfo does not matter,
acc.end = datetime(2011, 11, 13, 10, 0) # it's set by subscription
# adapter
# If using EventAccessor's edit method, calling notify isn't needed
acc.edit(timezone=u'Europe/Vienna')
# accessor should return start/end datetimes in the event's timezone
self.assertEqual(
acc.start,
datetime(2011, 11, 13, 9, 0, tzinfo=vienna))
self.assertEqual(
acc.end,
datetime(2011, 11, 13, 10, 0, tzinfo=vienna))
# start/end dates are stored in UTC zone on the context, but converted
# to event's timezone via the attribute getter.
self.assertEqual(
e1.end(),
DateTime('2011/11/13 10:00:00 Europe/Vienna')
)
# timezone should be the same on the event object and accessor
self.assertEqual(e1.getTimezone(), acc.timezone)
# Open End Test
acc.edit(open_end=True)
self.assertEqual(
acc.start,
datetime(2011, 11, 13, 9, 0, tzinfo=vienna))
self.assertEqual(
acc.end,
datetime(2011, 11, 13, 23, 59, 59, tzinfo=vienna))
# Whole Day Test
acc.edit(whole_day=True, open_end=False)
self.assertEqual(
acc.start,
datetime(2011, 11, 13, 0, 0, tzinfo=vienna))
self.assertEqual(
acc.end,
datetime(2011, 11, 13, 23, 59, 59, tzinfo=vienna))
# TEST DESCRIPTION
self.assertTrue(acc.description == 'a description')
acc.description = 'another desc'
self.assertTrue(acc.description == 'another desc')
# TEST OTHER PROPERTIES
acc.title = u"An Event"
acc.recurrence = u'RRULE:FREQ=DAILY;COUNT=5'
acc.location = u"Home"
acc.attendees = [u'me', u'you']
acc.contact_name = u"Max Mustermann"
acc.contact_email = u"[email protected]"
acc.contact_phone = u"+1234567890"
acc.event_url = u"http://plone.org/"
acc.subjects = [u"tag1", u"tag2"]
acc.text = u"body text with <b>html</b> formating."
# If not using EventAccessor's edit method, call notify manually
notify(ObjectModifiedEvent(acc.context))
self.assertEqual(acc.recurrence, u'RRULE:FREQ=DAILY;COUNT=5')
self.assertEqual(acc.location, u'Home')
self.assertEqual(acc.attendees, (u'me', u'you'))
self.assertEqual(acc.contact_name, u"Max Mustermann")
self.assertEqual(acc.contact_email, u'[email protected]')
self.assertEqual(acc.contact_phone, u"+1234567890")
self.assertEqual(acc.event_url, u"http://plone.org/")
self.assertEqual(acc.subjects, (u"tag1", u"tag2"))
self.assertEqual(acc.text, u"body text with <b>html</b> formating.")
# CLEANUP
self.portal.manage_delObjects(['event1'])