linkedin / pyexchange

Python wrapper for Microsoft Exchange
Apache License 2.0
153 stars 93 forks source link

TypeError: 'Exchange2010CalendarEventList' object is not iterable #54

Open nlamirault opened 9 years ago

nlamirault commented 9 years ago

I can retrieve all my events from calendar (like this [1]) but objet is not iterable :

events = cal.list_events(start, end, details=True)
print("Events: %s" % events)
for event in events:
     print "{start} {stop} - {subject}".format(
        start=event.start,
        stop=event.end,
        subject=event.subject
    )

I've got this error :

TypeError: 'Exchange2010CalendarEventList' object is not iterable

I'm using v0.6

[1] : https://pyexchange.readthedocs.org/en/latest/#listing-events

nlamirault commented 9 years ago

Checking unit tests, i find my error. It works now :

events = cal.list_events(start, end, details=True)
for event in events.events:
   print "{start} {stop} - {subject}".format(
        start=event.start,
        stop=event.end,
        subject=event.subject
    )

You should update documentation like this :

events = my_calendar.list_events(
    start=timezone("US/Eastern").localize(datetime(2014, 10, 1, 11, 0, 0)),
    end=timezone("US/Eastern").localize(datetime(2014, 10, 29, 11, 0, 0)),
    details=True
)

for event in events.events:
    print "{start} {stop} - {subject}".format(
        start=event.start,
        stop=event.end,
        subject=event.subject
    )