我尝试使用googleapi for python删除日历中的所有事件。 如果我一个接一个地删除事件,这很好,但它很长,而且不是未优化的,所以我尝试使用ExecuteBatch来做同样的事情,我使用ExecuteBatch在日历中插入很多条目(在插入之前,这个操作很好)。在
def DeleteAllEntryOfCalendar(calendar_client, name_calendar):
#Request_feed for doing the delete
request_feed = gdata.calendar.CalendarEventFeed()
#Get the Uri of the cal we've to delete all entries
uri = GetUri(calendar_client, name_calendar)
feed = calendar_client.GetAllCalendarsFeed()
for a_cal in feed.entry:
if a_cal.title.text == name_calendar:
calendar = a_cal
#For each entry in the cal, do a delete request entry in request_feed
query = gdata.calendar.client.CalendarEventQuery()
query.max_results = 1000
feed = calendar_client.GetCalendarEventFeed(uri=uri, q=query)
for an_entry in feed.entry:
an_entry.batch_id = gdata.BatchId(text='delete-request')
request_feed.AddDelete(entry=an_entry)
entry = ''
# submit the batch request to the server
response_feed = calendar_client.ExecuteBatch(request_feed, uri+u'/batch')
我得到了一个错误:
^{pr2}$我重复一下,当我做同样的事情来插入事件时,效果很好。 我搜索了很多,尝试了很多可能性,但我做不到。 如果你有主意。。。在
使用
gdatapython库中的一些对象有两个版本,您不能将它们混合在一起。在
相关问题 更多 >
编程相关推荐