Database Reference
In-Depth Information
Listing 9-23. The friends Route and the following Method
@route('/friends', method='GET')
def friends():
following = User().following(graph_db, request.get_cookie(graphstoryUserAuthKey))
return template('public/templates/graphs/social/friends.html',
following=following, layout=applayout, title="Friends")
# the following method in the User class
def following(self, graph_db, username):
query = neo4j.CypherQuery(graph_db,
" MATCH (user { username:{u}})-[:FOLLOWS]->(users) " +
" RETURN users.firstname as firstname, users.lastname as
lastname,"+
" users.username as username " +
" ORDER BY users.username")
params = {"u": username}
result = query.execute(**params)
return result
If the list contains users, it will be returned to the controller and displayed as on the right-hand part of Figure 9-9 .
The display code for showing the list of users can be found in {PROJECTROOT}/app/public/templates/graphs/social/
friends.html and is shown in the code snippet in Listing 9-24.
Figure 9-9. The Friends page
Search WWH ::




Custom Search