Archive for the ‘SecondaryCalendarEvents’ Category
Posted on September 28th, 2008 by Ray Baxter (4) Comments
Before writing, I assumed that I would need to refer any reader to the introductory post of this series on adding events to secondary calendars. Depending on your skill level and experience that may still be true, and it definitely is true if you want to understand what you are doing, but if you just want to get it done, you can probably muddle through with the following instructions.
Here’s the really short story: when you call the insertEvent method, you pass the event that you are creating and optionally, the edit url of the calendar where you want the event to appear. So, to create an event on a secondary calendar, just pass the edit link of the calendar. (You can get the edit link of a calendar in python by calling
GetEditLink().href on it.)
For the longer story, I’ll assume that you have installed Python, ElementTree and the Google Data Python Library, following Google’s instructions.
Run through the tests and the sample code. When I ran the calendarExample.py it failed with this stack trace:
Traceback (most recent call last): File "./samples/calendar/calendarExample.py", line 577, in <module> main() File "./samples/calendar/calendarExample.py", line 574, in main sample.Run(delete) File "./samples/calendar/calendarExample.py", line 498, in Run self._PrintAllEventsOnDefaultCalendar() File "./samples/calendar/calendarExample.py", line 99, in _PrintAllEventsOnDefaultCalendar print '\t\t\t%s' % (a_participant.attendee_status.value,) AttributeError: 'NoneType' object has no attribute 'value'
Since all I wanted to do was to make this sample code run for the single case of adding an event to a secondary calendar, I commented out line 99, but the code should be checking that there is an attendee status before writing its value. After that change the sample code ran fine for me.
To insert a single event in a secondary calendar, I copied
secondaryCalendarInsert.py. Then I commented out everything in the
Run method except this line:
see = self._InsertSingleEvent()
and made the following change,
new_event = self.cal_client.InsertEvent(event, '/firstname.lastname@example.org/private/full')
This instructs the InsertEvent method to create the event in my secondary calendar by
POSTing to the url of my “Secondary Calendar” (id
email@example.com) instead of my primary calendar (id
default). I found the calendar ID on the calendar settings page of the calendar, but as I said above, if you have accessed a calendar programatically, you can just call
GetEditLink().href on it to get the proper link.
You can see that a “One Time Tennis with Beth” event was inserted beginning at the moment I did the insert and lasting for one hour, as described in the sample code.
[Update 2008-11-14: You can't see this if you are using Safari. In general embedded calendar's show in Safari, but there is something about this particular calendar that causes it not to display. Google does a number of separate calls and redirects to obtain the correct data for this calendar and it looks like one of the calls returns data that doesn't correspond to the mime-types. The point that I was trying to communicate with this illustration was that the event did in fact appear and that it was on the secondary calendar.]
Posted on September 1st, 2008 by Ray Baxter (5) Comments
The most frequently asked question posed in the Google Calendar Date API Group is, “How do I add events to a secondary calendar?”
I start with describing how to POST XML to a calendar url. This is “The Protocol”. You should read this information about the protocol, even if you plan to use a client library. Each client library is using this protocol under the covers, so understanding what is happening will help you better use your client library. In addition, I’ll only explain some terms in this section, so you’ll need to read it to understand what I am talking about.
All information in these posts comes from the Google Developer’s Guides, the Client Library Documentation, the source code for the client library and my own exploration and testing. I’ll provide links to these resources in the text as appropriate. For simplicity’s sake, I only cover creating single-occurrence events for users that have properly authenticated using client login. These cases should be sufficient for illustrating how to add to secondary calendars, but 1) I’m not aware of any differences in creating single-occurrence versus quickadd or recurrent events on secondary calendars in any of the client libraries and 2) I haven’t used AuthSub.
I have personally tested all of the code that I present here, unless otherwise noted. That means that I was able to create an event on a calendar using that code. In all cases, I am adding events to my Secondary Calendar which is public, so have a look. I’ll be trying to add an event that occurs at the time when the relevant article is posted.
Here is a table of contents of the language-specific treatments. I’ll update the links as I complete the sections.
Python – Complete September 29, 2008
- Fix a Typo, Go to Rails
- Embedding Private and Shared Calendars – Google Apps for Your Domain
- Embedding Private and Shared Google Calendars
- Restyle Google Calendar
- Single Purpose Web Dev Browser
- No categories
- 2445 – iCalendar
- 2518 – Webdav
- 2616 – HTTP/1.1
- 30 Boxes
- 4287 – Atom
- 5023 – Atom Pub
- API Documentation
- Articles and Tutorials
- Batch Processing
- Bee Docs’ Timeline
- Bugs and Enhancements
- Calendar API FAQ
- Calendar Feeds
- CalendarHub – Web Calendars
- Client Libraries
- Common Elements
- Developer’s Guide
- exchange2ical available on CodePlex � Jon Udell
- Explaining REST …
- Framework Documentation
- Getting to know the Atom Publishing Protocol, Part 1: Create and edit Web resources with the Atom Publishing Protocol
- Getting to know the Atom Publishing Protocol, Part 2: Put the Atom Publishing Protocol (APP) to work
- Google Calendar
- Google Calendar Data API Group
- How to Create a REST Protocol
- iCalendar Validator
- Official US time
- Online calendar publishing: Google Calendar
- Online calendar publishing: iCal
- Online calendar publishing: Outlook
- Programmer’s Reference
- Protocol Basics
- Protocol Reference
- Reference Guide
- The Human Calendar
- Timetoast Timelines
- United States Naval Observatory
- Yahoo! Calendar
- Zend Documentation