async def follow_user(self, request):
        """Adds the current user as follower of the given user."""
        username = request.match_info['username']
        session = await get_session(request)
        user_id = session.get('user_id')

        if not user_id:
            raise web.HTTPNotAuthorized()

        whom_id = await db.get_user_id(self.mongo.user, username)

        if whom_id is None:
            raise web.HTTPFound()

        await self.mongo.follower.update(
            {'who_id': ObjectId(user_id)},
            {'$push': {'whom_id': whom_id}}, upsert=True)

        return redirect(request, 'user_timeline', parts={"username": username})
async def follow_user ( self , request ) : username = request . match_info [ 'username' ] session = await get_session ( request ) user_id = session . get ( 'user_id' ) if not user_id : raise web . HTTPNotAuthorized ( ) whom_id = await db . get_user_id ( self . mongo . user , username ) if whom_id is None : raise web . HTTPFound ( ) await self . mongo . follower . update ( { 'who_id' : ObjectId ( user_id ) } , { '$push' : { 'whom_id' : whom_id } } , upsert = True ) return redirect ( request , 'user_timeline' , parts = { "username" : username } )
Adds the current user as follower of the given user.