def get(self, name=False):
        self.response.headers.add_header("Access-Control-Allow-Origin", "*")
        user = auth.getCurrentUser()
        response = {}
        if user:
            try:
                user_data = models.getUser(user)
            except models.UserDoesNotExistError:
                user_data = models.UserData(user=user).save()
            if not name:
                name = "Chrome"
            try:
                device = models.getDevice("%s/%s" % (user.email(), name))
            except models.DeviceDoesNotExistError:
                device = models.DeviceData(user=user_data, name=name).save()
            try:
                channel = channels.Channel(device.address,
                        override_quota=user_data.immune())
                response['token'] = channel.token
                if channel.cached:
                    response['code'] = 304
                else:
                    response['code'] = 200
            except channels.OverQuotaError:
                response['code'] = 503
                response['token'] = 'overquota'
                response['message'] = "Server is over quota."
        else:
            response['code'] = 401
            response['message'] = 'Not logged in.'
        self.response.out.write(simplejson.dumps(response))
dataset/ETHPy150Open 2cloud/AppEngine/devlinks.py/TokenPage.get/original