Hi,
I have this code sample that may be helpful to you, the following method
perform a date range query and delete them in the process -
def deleteEventsWithDateRange():
username = '[EMAIL PROTECTED]'
visibility = 'private'
projection = 'full'
query = gdata.calendar.service.CalendarEventQuery(username, visibility,
projection)
query.start_min = '2008-05-01'
query.start_max = '2008-06-30'
feed = calendar_service.CalendarQuery(query)
for an_event in feed.entry:
print 'Title: %s' % (an_event.title.text,)
print 'Location: %s' % (an_event.where[0].value_string,)
print 'Content: %s' % (an_event.content.text,)
calendar_service.DeleteEvent(an_event.GetEditLink().href)
print 'deleting ...'
when = an_event.when
print when[0].start_time
Hope that helps,
Austin
On Mon, May 26, 2008 at 10:32 PM, Nathan <[EMAIL PROTECTED]> wrote:
>
>
> Can I create a query to retrieve events between a date range and then
> delete each of those events ?
>
> Below is a program fragment. The first loop works and prints out info
> on the events between the first of the year and two days ago.
>
> The second loop has a compiler error. I realize that an_event2 is not
> of the proper type. I apologize for the sloppy code. I'm no python
> expert. I was trying to piece things together from the documentation
> samples. I only found samples where events to delete had been just
> added.
>
> query = gdata.calendar.service.CalendarEventQuery('default',
> 'private', 'full')
> query.start_min = '2008-01-01'
>
> today = datetime.date.today()
> twodays = datetime.timedelta(days=2)
> twodaysago = today
> twodaysago -= twodays
>
> query.start_max = twodaysago.strftime('%Y-%m-%d')
> feed = calendar_service.CalendarQuery(query)
> for i, an_event in enumerate(feed.entry):
> print '\t%s. %s' % (i, an_event.title.text,)
> for a_when in an_event.when:
> print '\t\tStart time: %s' % (a_when.start_time,)
> print '\t\tEnd time: %s' % (a_when.end_time,)
>
> feed = calendar_service.CalendarQuery(query)
> for an_event2 in enumerate(feed.entry):
> calendar_service.DeleteEvent(an_event2.GetEditLink().href)
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---