Hi Mike,
I have been working on a sample app here and there which allows users
to create an event and optionally add it to their Google Calendar.
Since the primary storage for these events in my example app is in the
App Engine datastore, I've defined a model for an event:
class Event(db.Model):
title = db.StringProperty(required=True)
description = db.TextProperty()
time = db.DateTimeProperty()
creator = db.UserProperty()
edit_link = db.TextProperty()
gcal_event_link = db.TextProperty()
class Attendee(db.Model):
email = db.StringProperty()
event = db.ReferenceProperty(Event)
You probably don't need this, but I point it out because I use these
models to construct the Google Caledar event Atom entry which I send
using the gdata-python-client. Adding the event to Google Calendar in
my sample app looks like this:
# Create a Google Calendar client to talk to the Google Calendar
service.
self.calendar_client = gdata.calendar.service.CalendarService()
# Modify the client to search for auth tokens in the datastore and
use
# urlfetch instead of httplib to make HTTP requests to Google
Calendar.
gdata.alt.appengine.run_on_appengine(self.calendar_client)
...
# Create a new Google Calendar event.
event_entry = gdata.calendar.CalendarEventEntry()
event_entry.title = atom.Title(text=event.title)
event_entry.content = atom.Content(text=event.description)
start_time = '%s.000Z' % event.time.isoformat()
event_entry.when.append(gdata.calendar.When(start_time=start_time))
# Add a who element for each attendee.
if attendee_list:
for attendee in attendee_list:
new_attendee = gdata.calendar.Who()
new_attendee.email = attendee.email
event_entry.who.append(new_attendee)
# Send the event information to Google Calendar and receive a
# Google Calendar event.
try:
cal_event = self.calendar_client.InsertEvent(event_entry,
'http://www.google.com/calendar/feeds/default/private/
full')
edit_link = cal_event.GetEditLink()
if edit_link and edit_link.href:
# Add the edit link to the Calendar event to use for making
changes.
event.edit_link = edit_link.href
alternate_link = cal_event.GetHtmlLink()
if alternate_link and alternate_link.href:
# Add a link to the event in the Google Calendar HTML web
UI.
event.gcal_event_link = alternate_link.href
event.put()
except gdata.service.RequestError, request_exception:
request_error = request_exception[0]
# Handle any insert failures here.
Note in the above I require the user to be signed in to the app before
getting to the event creation step. Note also, I'm interested in
saving the edit link from the Google Calendar event entry, which is
the URL which needs to be used when sending event changes to Google
Calendar. I also save the alternate link which is the ULR of the event
in the Google Calendar UI.
Please refer to the Google Calendar developer's guide for a more
detailed list of the what and how of using the Python client library
with Google Calendar:
http://code.google.com/apis/calendar/developers_guide_python.html
Happy coding,
Jeff
On Oct 29, 1:15 pm, "Mike Metcalfe" <[EMAIL PROTECTED]> wrote:
> Hi Jeff,
>
> 2008/10/29 Jeff S <[EMAIL PROTECTED]>
>
> > I'm not sure what you mean by the two interfaces. Could you describe
> > these in more detail?
>
> The only python development I've done before is using Zope and Plone which
> allow interface classes and the base classes have an 'implements' method.
> This allows you to have one class implement another class's behaviour
> without subclassing it - allowing inheritance from more than one super
> class. I was hoping to have my Resource class implement the Calendar's
> behaviour. I suppose it should just use normal subclassing.
>
> As far as using the Google Calendar Data API> from within App Engine, I have
> some sample code if you are interested.
>
> I'm interested!
>
> Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" 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-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---