udacity / ud858 Goto Github PK
View Code? Open in Web Editor NEWPython version of the Conference Central app for Udacity course on Google App Engine
License: GNU General Public License v3.0
Python version of the Conference Central app for Udacity course on Google App Engine
License: GNU General Public License v3.0
Adding a README file with a link back to the course would be a nice addition.
In the videos for "Using Transactions", the getConference endpoint appears functional when the instructor uses the site. However, this code is not in any TODO files in lesson 4. Per the forums, this issue was first raised in June.
When the Conference app web page is refreshed at the /#/conference link, the endpoints API query fails due to the queryConferences
endpoint method not being initialized. After the page is loaded, clicking on a different tab works fine, and then clicking on the "All" tab works.
The error is
TypeError: Cannot read property 'queryConferences' of undefined at angular.js:9778
It seems the bootstrapping method for loading the google API does complete in time if the initial page being loaded makes an endpoints API call.
conference.maxAttendees
is 3
(Registered/Open: 0/3)The getConference
API endpoint returns a ConferenceForm object in which all IntegerField
values are actually encoded as strings (wrapped in double quotes), as opposed to integers (no double quotes). This encoding is performed by an internal Google Endpoints method called EndpointsProtoJson.encode_field
which is executed during the JSON-encoding process. Due to the integers being encoded as strings in the returned JSON, conference.seatsAvailable
(in controller.js
) ends up pointing to a string object that represents the number of seats available in the conference, rather than a number object. When the controller.js
function unregisterFromConference
function gets called, it attempts to add the number 1
to conference.seatsAvailable
, but instead the number 1
is converted to a string and concatenated onto the end. In step 5 of the above problem statement, conference.seatsAvailable
would point to the string '21'
(the concatenation of the string '2'
and the number 1
). This causes the calculation in conference_detail.html
, conference.maxAttendees - conference.seatsAvailable
to yield the result -18
, instead of the intended 3
. The subtraction operator causes both operands to be converted to number objects, then the subtraction is carried out, whereas the addition operator in unregisterFromConference
is interpreted as a concatenation operator. If steps 3 and 4 in the above problem statement are skipped, the correct result would be displayed. This is because step 2 causes the controller.js
function registerForConference
to execute, which subtracts 1
from conference.seatsAvailable
thus converting it from a string object to a number object prior to step 5 executing. In this instance, the addition operator does not get interpreted as the concatenation operator because neither of the operands is a string. The addition is then carried out and the correct result displayed.
A solution to this type of problem is to add a keyword argument called variant
with a value of messages.Variant.INT32
to the IntegerField
constructor calls in the ConferenceForm
class definition in models.py
. This prevents the integer values from being wrapped in double quotes in the JSON returned by the API, thus ensuring the values are represented properly in the front-end JavaScript code. As a result, all calculations yield the intended results.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.