App Engine application for the Udacity training course.
You can visit already deployed application on this link
How to setup:
- Download and install the Google App Engine SDK for Python. The App Engine SDK includes command-line tools and libraries for developing apps on your computer, testing them with a local server, and deploying them to App Engine.
- Create or select a project in Google App Engine Developer Console.
- Update the value of
application
inapp.yaml
to the app ID you have registered in the App Engine admin console and would like to use to host your instance of this sample. - Update the values at the top of
settings.py
to reflect the respective client IDs you have registered in the Developer Console. - Update the value of CLIENT_ID in
static/js/app.js
to the Web client ID - Run the app with the devserver using
dev_appserver.py DIR
, and ensure it's running by visiting your local server's address (by default localhost:8080.) - Generate your client library(ies) with the endpoints tool.
- Deploy your application.
To support Sessions and Speakers the following was implemented:
- Models
Session
model with properties:sessionName
- name of Session (string property)highlights
- abstract of Session (string property)speaker
- Speakers key in datastore (key property)duration
- duration of Session (integer property)typeOfSession
- type of Session (string property). Available types:- Lecture
- Workshop
- Keynote
date
- date of Session (date property)startTime
- start time of Session (time property)
Speaker
model with properties:displayName
- name of Speaker (string property)mainEmail
- email of Speaker (string property)
- Messages
SessionForm
- update Session form messageSessionForms
- multiple Session outbound form messageSpeakerForm
- Speaker outbound form message
- Endpoints
getConferenceSessions
- given a conference (by websafeConferenceKey), return all sessionsgetConferenceSessionsByType
- given a conference (by websafeConferenceKey) and session type, return all sessionsgetConferenceSessionsBySpeaker
- given speaker, return all sessionscreateSession
- create a new SessiongetSpeaker
- return speaker profile by keycreateSpeaker
- create Speaker profile
- Helpers
_copySessionToForm
- copy relevant fields from Session to SessionForm_createSessionObject
- create Session object, returning SessionForm/request_copySpeakerProfileToForm
- copy relevant fields from Speaker to SpeakerForm
Each Conference can contain several Sessions. Ancestor relationship was used to model this relation. Sessions unique key is created using Conference key. So particular Conference is a parent for particular set of Sessions.
Each Session has only one Speaker and one Speaker can conduct several Sessions in several Conferences. I decide to create separate Speaker entity instead of just speaker property in Sessions entity because I want to be able to store more information about Speaker than just his name. I store for example list of Sessions that Speaker conducted.
To implement users wishlist sessionsWishlist
property was added to Profile entity. This property stores Sessions keys that were added to wishlist by user. Also was added the following endpoints:
getSessionsInWishlist
- get list of sessions that user has added to wishlistaddSessionToWishlist
- add session to users wishlistdeleteSessionInWishlist
- delete session from users wishlist
To get sessions from wishlist was used ndb.get_multi
method. And to add or delete sessions to/from wishlist was implemented _addToWishlist
helper function where appropriate users list is updated depending on what we want - add or delete appropriate session.
The following additional queries were implemented:
queryLongSessions
- query for sessions with duration more than 60. This query is useful if user want to filter long sessions.getConferenceBySession
- given a Session key, return appropriate Conference. This query is useful if user want to found conference if he know only Session.
For each additional query, appropriate endpoint was implemented.
Also queryBefore7pmNotWorkshops
endpoint was implemented to filter non-Workshop sessions which starts before 19PM. As we can't filter with inequalities for different properties (in our case non-Workshop is !=
inequality and before 7PM is <
inequality) I used IN
operator to filter only Lecture
and Keynote
types of sessions. Here is more info about it:
https://cloud.google.com/appengine/docs/python/datastore/queries.
I chose usage of IN
operator, as it is the simplest way to build such query if types of Session are hardcoded.
Also I have found other method with MultiInequalityMixin
class that in some cases can be implemented to handle queries with multiple inequality: see Multiple Inequalities in Google AppEngine article for more details.
Featured Speaker is a speaker with more than one session in one conference. It was implemented via App Engine's Task Queue. When session is created, appropriate speaker key and conference key is stored in task. Task handler start appropriate static method where I verify if speaker of added session has more than one session in provided conference. If so speaker name and his sessions in conference are stored in memcache. We can get featured speaker from memcache via getFeaturedSpeaker
endpoint.