def GetCalendar(client, obj_store, user_id, device_id, request, callback):
 def _OnQueryUser(user):
  calendars = request['calendars']
  response = {'calendars': []}
  for cal in calendars:
   if (cal['calendar_id'] == 'holidays'):
    cal_data = Calendar.GetHolidaysByLocale(user.locale)
   else:
    cal_data = Calendar.GetCalendar(cal['calendar_id'])
   response['calendars'].append({'calendar_id': cal_data.calendar_id, 'year': cal['year'], 'events': cal_data.GetEvents(year=cal['year'])})
  logging.info(('GET CALENDAR: user: %d, device: %d, %d calendars, event counts: %s' % (user_id, device_id, len(calendars), dict([(c['calendar_id'], len(c['events'])) for c in response['calendars']]))))
  callback(response)
 User.Query(client, user_id, None, _OnQueryUser)

def GetCalendar ( client , obj_store , user_id , device_id , request , callback ) : def _OnQueryUser ( user ) : calendars = request [ 'calendars' ] response = { 'calendars' : [ ] } for cal in calendars : if ( cal [ 'calendar_id' ] == 'holidays' ) : cal_data = Calendar . GetHolidaysByLocale ( user . locale ) else : cal_data = Calendar . GetCalendar ( cal [ 'calendar_id' ] ) response [ 'calendars' ] . append ( { 'calendar_id' : cal_data . calendar_id , 'year' : cal [ 'year' ] , 'events' : cal_data . GetEvents ( year = cal [ 'year' ] ) } ) logging . info ( ( 'GET CALENDAR: user: %d, device: %d, %d calendars, event counts: %s' % ( user_id , device_id , len ( calendars ) , dict ( [ ( c [ 'calendar_id' ] , len ( c [ 'events' ] ) ) for c in response [ 'calendars' ] ] ) ) ) ) callback ( response ) User . Query ( client , user_id , None , _OnQueryUser )
queries calendar(s) for the user for the specified year .