예제 #1
0
def get_calendar(user, calendar_name):
    cal_query = Calendar.query(ancestor=user.key)\
                        .filter(ndb.AND(Calendar.owner==user.key,
                                        Calendar.name==calendar_name))
    calendars = cal_query.fetch()
    if len(calendars) == 0:
        raise DoesNotExistError('Calendar %s owned by %s does not exist',
                                calendar_name, user.username)
    if len(calendars) > 1:
        raise Exception('This should never happen')
    return calendars[0]
예제 #2
0
def query_user_calendars(email):
    user = get_user_from_email(email)
    calendar_query = Calendar.query(ancestor=user.key)\
                             .order(Calendar.name)
    return calendar_query