本文整理汇总了Python中plone.event.interfaces.IEventAccessor.last_modified方法的典型用法代码示例。如果您正苦于以下问题:Python IEventAccessor.last_modified方法的具体用法?Python IEventAccessor.last_modified怎么用?Python IEventAccessor.last_modified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plone.event.interfaces.IEventAccessor
的用法示例。
在下文中一共展示了IEventAccessor.last_modified方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ical_import
# 需要导入模块: from plone.event.interfaces import IEventAccessor [as 别名]
# 或者: from plone.event.interfaces.IEventAccessor import last_modified [as 别名]
#.........这里部分代码省略.........
location = _get_prop('LOCATION', item)
url = _get_prop('URL', item)
rrule = _get_prop('RRULE', item)
rrule = rrule and 'RRULE:%s' % rrule.to_ical() or ''
rdates = _from_list(item, 'RDATE')
exdates = _from_list(item, 'EXDATE')
rrule = '\n'.join([it for it in [rrule, rdates, exdates] if it])
# TODO: attendee-lists are not decoded properly and contain only
# vCalAddress values
attendees = item.get('ATTENDEE', ())
contact = _get_prop('CONTACT', item)
categories = item.get('CATEGORIES', ())
if hasattr(categories, '__iter__'):
categories = [safe_unicode(it) for it in categories]
ext_modified = utc(_get_prop('LAST-MODIFIED', item))
# TODO: better use plone.api for content creation, from which some of
# the code here is copied
content = None
new_content_id = None
existing_event = None
sync_uid = _get_prop('UID', item)
if sync_strategy != base.SYNC_NONE and sync_uid:
existing_event = _get_by_sync_uid(sync_uid)
if existing_event:
if sync_strategy == base.SYNC_KEEP_MINE:
# On conflict, keep mine
continue
exist_event = existing_event[0].getObject()
acc = IEventAccessor(exist_event)
if sync_strategy == base.SYNC_KEEP_NEWER and\
(not ext_modified or acc.last_modified >= ext_modified):
# Update only, if newer, if ext_modified exists
continue
# Else: update
content = exist_event
else:
# TODO: if AT had the same attrs like IDXEventBase, we could set
# everything within this invokeFactory call.
new_content_id = str(random.randint(0, 99999999))
container.invokeFactory(event_type,
id=new_content_id,
title=title,
description=description)
content = container[new_content_id]
assert(content) # At this point, a content must be available.
event = IEventAccessor(content)
event.title = title
event.description = description
event.start = start
event.end = end
event.timezone = timezone
event.whole_day = whole_day
event.open_end = open_end
event.location = location
event.event_url = url
event.recurrence = rrule
event.attendees = attendees
event.contact_name = contact
event.subjects = categories
if sync_strategy != base.SYNC_NONE:
# Don't import the sync_uid, if no sync strategy is chosen. Let the
# sync_uid be autogenerated then.
event.sync_uid = sync_uid
notify(ObjectModifiedEvent(content))
# Archetypes specific code
if getattr(content, 'processForm', False):
# Will finish Archetypes content item creation process,
# rename-after-creation and such
content.processForm()
# Use commits instead of savepoints to avoid "FileStorageError:
# description too long" on large imports.
transaction.get().commit() # Commit before rename
if new_content_id and new_content_id in container:
# Rename with new id from title, if processForm didn't do it.
chooser = INameChooser(container)
new_id = chooser.chooseName(title, content)
content.aq_parent.manage_renameObject(new_content_id, new_id)
# Do this at the end, otherwise it's overwritten
if ext_modified:
event.last_modified = ext_modified
count += 1
return {'count': count}
示例2: ical_import
# 需要导入模块: from plone.event.interfaces import IEventAccessor [as 别名]
# 或者: from plone.event.interfaces.IEventAccessor import last_modified [as 别名]
#.........这里部分代码省略.........
title = _get_prop('SUMMARY', item)
description = _get_prop('DESCRIPTION', item)
location = _get_prop('LOCATION', item)
url = _get_prop('URL', item)
rrule = _get_prop('RRULE', item)
rrule = rrule.to_ical() if rrule else ''
if rrule:
if six.PY3 and isinstance(rrule, six.binary_type):
rrule = rrule.decode('utf8')
rrule = 'RRULE:%s' % rrule
rdates = _from_list(item, 'RDATE')
exdates = _from_list(item, 'EXDATE')
rrule = '\n'.join([it for it in [rrule, rdates, exdates] if it])
# TODO: attendee-lists are not decoded properly and contain only
# vCalAddress values
attendees = item.get('ATTENDEE', ())
contact = _get_prop('CONTACT', item)
categories = item.get('CATEGORIES', ())
if getattr(categories, '__iter__', False):
categories = tuple([safe_unicode(it) for it in categories])
ext_modified = utc(_get_prop('LAST-MODIFIED', item))
content = None
new_content_id = None
existing_event = None
sync_uid = _get_prop('UID', item)
if sync_uid and sync_strategy is not base.SYNC_NONE:
existing_event = _get_by_sync_uid(sync_uid)
if existing_event:
if sync_strategy == base.SYNC_KEEP_MINE:
# On conflict, keep mine
continue
exist_event = existing_event[0].getObject()
acc = IEventAccessor(exist_event)
if sync_strategy == base.SYNC_KEEP_NEWER and\
(not ext_modified or acc.last_modified > ext_modified):
# Update only if modified date was passed in and it is not
# older than the current modified date. The client is not
# expected to update the "last-modified" property, it is the
# job of the server (calendar store) to keep it up to date.
# This makes sure the client did the change on an up-to-date
# version of the object. See
# http://tools.ietf.org/search/rfc5545#section-3.8.7.3
continue
# Else: update
content = exist_event
else:
new_content_id = str(random.randint(0, 99999999))
container.invokeFactory(event_type,
id=new_content_id,
title=title,
description=description)
content = container[new_content_id]
assert(content) # At this point, a content must be available.
event = IEventAccessor(content)
event.title = title
event.description = description
event.start = start
event.end = end
event.whole_day = whole_day
event.open_end = open_end
event.location = location
event.event_url = url
event.recurrence = rrule
event.attendees = attendees
event.contact_name = contact
event.subjects = categories
if sync_uid and sync_strategy is not base.SYNC_NONE:
# Set the external sync_uid for sync strategies other than
# SYNC_NONE.
event.sync_uid = sync_uid
notify(ObjectModifiedEvent(content))
# Use commits instead of savepoints to avoid "FileStorageError:
# description too long" on large imports.
transaction.get().commit() # Commit before rename
if new_content_id and new_content_id in container:
# Rename with new id from title, if processForm didn't do it.
chooser = INameChooser(container)
new_id = chooser.chooseName(title, content)
content.aq_parent.manage_renameObject(new_content_id, new_id)
# Do this at the end, otherwise it's overwritten
if ext_modified:
event.last_modified = ext_modified
count += 1
return {'count': count}