Database Reference
In-Depth Information
Figure 9-7. The social graph home page
Login Service
To check to see if the user values being passed through are connected to a valid user combination in the database,
the application uses the get_user_by_username method in the User class . As shown in Listing 9-19, the result of the
get_user_by_username method is assigned to the user variable.
If the result is not null or empty, the result is set on the User object and returned to the controller layer of the
application.
Listing 9-19. The get_user_by_username Method in the User Class
def get_user_by_username(self, graph_db, username):
query = neo4j.CypherQuery(graph_db,
" MATCH (user:User {username: {username}}) " +
" RETURN user ")
params = {"username": username}
result = query.execute_one(**params)
return result
Now that the user is logged in, he can edit his settings, create relationships with other users in the graph, and
create his own content.
Updating a User
To access the page for updating a user, click on the “User Settings” link in the social graph section, as shown in
Figure 9-8 . In this example, the front-end code uses an AJAX request via PUT and adds—or, in the case of the ajordan
user, updates—the first and last name of the user.
 
Search WWH ::




Custom Search