• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Client类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.Client的典型用法代码示例。如果您正苦于以下问题:Python Client类的具体用法?Python Client怎么用?Python Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Client类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: register

 def register(self):
     if request.method == u'POST':
         client_key = self.generate_client_key()
         secret = self.generate_client_secret()
         # TODO: input sanitisation?
         name = request.form.get(u"name")
         description = request.form.get(u"description")
         callback = request.form.get(u"callback")
         pubkey = request.form.get(u"pubkey")
         # TODO: redirect?
         # TODO: pubkey upload
         # TODO: csrf
         info = {
             u"client_key": client_key,
             u"name": name,
             u"description": description,
             u"secret": secret,
             u"pubkey": pubkey
         }
         client = Client(**info)
         client['callbacks'].append(callback)
         client['resource_owner_id'] = g.user['_id']
         client_id = Client.insert(client)
         g.user.client_ids.append(client_id)
         User.get_collection().save(g.user)
         return render_template(u"client.html", **info)
     else:
         clients = Client.get_collection().find({'_id': {'$in': 
             [ObjectId(oid) for oid in g.user.client_ids]}})
         return render_template(u"register.html", clients=clients)
开发者ID:Chitrank-Dixit,项目名称:flask-oauthprovider,代码行数:30,代码来源:provider.py


示例2: authorize

def authorize():
    if request.method == "GET":
        print "123445566"
        context_id = None
        # scopes requesting resource accesses
        resource_scopes = []
        for scope in request.args["scope"].split(" "):
            if scope.startswith("launch:"):
                _, context_id = scope.rsplit(":", 1)
            elif scope.startswith("patient/") or scope.startswith("user/"):
                resource_scopes.append(scope)
        if context_id is None:
            # create launch context for app launched outside of EHR env
            # TODO clean this up
            return redirect(
                "%s?%s" % (url_for("auth.create_context"), urlencode({"auth_req": json.dumps(request.args)}))
            )
        assert request.args["response_type"] == "code"
        # find app requested this authorization
        app = App.query.filter_by(
            client_id=request.args["client_id"], redirect_uri=request.args["redirect_uri"]
        ).first()
        assert app is not None
        client = Client(
            authorizer=request.session.user,
            app=app,
            state=request.args.get("state"),
            scope=request.args["scope"],
            context_id=context_id,
        )
        db.session.add(client)
        ctx = Context.query.get(context_id)
        # id of patient selected in launch time, could be none
        pid = json.loads(ctx.context).get("Patient")
        # parse requested scopes
        scopes = [OAuthScope(scp_str, pid) for scp_str in resource_scopes]
        readable_accesses = map(OAuthScope.to_readable, scopes)
        # we grant access despite user's reaction so that we don't have to keep tract of requested scope
        # security is being taken care of by marking the authorized client as un authorized
        for scope in scopes:
            scope.get_access_from_user(request.session.user, client)
        db.session.commit()
        return render_template(
            "authorization.html", appname=app.name, accesses=readable_accesses, auth_code=client.code
        )
    else:
        client = Client.query.filter_by(code=request.form["auth_code"]).first()
        assert client is not None
        app = App.query.filter_by(client_id=client.client_id).first()
        redirect_uri = app.redirect_uri
        if request.form["authorize"] == "yes":
            # authorize the client and redirect
            client.authorized = True
            db.session.commit()
            redirect_args = {"code": request.form["auth_code"]}
            if client.state is not None:
                redirect_args["state"] = client.state
        else:
            redirect_args = {"error": "Authorization declined"}
        return redirect("%s?%s" % (redirect_uri, urlencode(redirect_args)))
开发者ID:bmilius-nmdp,项目名称:FHIR-Genomics-2,代码行数:60,代码来源:oauth.py


示例3: register

 def register(self):
     if request.method == u'POST':
         client_key = self.generate_client_key()
         secret = self.generate_client_secret()
         # TODO: input sanitisation?
         name = request.form.get(u"name")
         description = request.form.get(u"description")
         callback = request.form.get(u"callback")
         pubkey = request.form.get(u"pubkey")
         # TODO: redirect?
         # TODO: pubkey upload
         # TODO: csrf
         info = {
             u"client_key": client_key,
             u"name": name,
             u"description": description,
             u"secret": secret,
             u"pubkey": pubkey
         }
         client = Client(**info)
         client.callbacks.append(Callback(callback))
         client.resource_owner = g.user
         db_session.add(client)
         db_session.commit()
         return render_template(u"client.html", **info)
     else:
         clients = g.user.clients
         return render_template(u"register.html", clients=clients)
开发者ID:felixhummel,项目名称:flask-oauthprovider,代码行数:28,代码来源:provider.py


示例4: delete_client

 def delete_client(self, cmd, anon_ch):
     valid, msg, owner = self.check_del_params(cmd)
     if not valid:
         anon_ch.put({'status': 'error',
                      'message': 'Invalid parameters sent: {}'.format(msg)})
         return None
     try:
         _, ag = self.get_agave(cmd['tenant'], owner)
     except ClientException as e:
         anon_ch.put({'status': 'error',
                      'message': 'Could not generate an Agave client: {}'.format(e)})
         return None
     # remove the client from APIM
     try:
         ag.clients.delete(clientName=cmd['worker_id'])
     except Exception as e:
         anon_ch.put({'status': 'error',
                     'message': 'Not able to delete client from APIM. Exception: {}'.format(e)})
         return None
     # remove the client from the abaco db
     try:
         Client.delete_client(tenant=cmd['tenant'], client_key=cmd['client_id'])
     except Exception as e:
         anon_ch.put({'status': 'error',
                     'message': 'Not able to delete client from abaco db. Exception: {}'.format(e)})
         return None
     anon_ch.put({'status': 'ok',
                  'message': 'Client deleted.'})
开发者ID:TACC,项目名称:abaco,代码行数:28,代码来源:clients.py


示例5: test_one_report

 def test_one_report(self):
   client = Client(product=ProductData.killerapp_obj, cookie='123')
   client.put()
   report = Report(product=ProductData.killerapp_obj, client=client, status=REPORT_NEW, remote_ip='127.0.0.1', data='[]')
   report.put()
 
   response = self.get('/status/')
   assert 'Queued Reports: 1' in str(response)
开发者ID:B-Rich,项目名称:crashkit,代码行数:8,代码来源:test_status.py


示例6: management

def management():
    """ This endpoint is for vieweing and adding users and clients. """
    if request.method == 'POST' and request.form['submit'] == 'Add User':
        User.save(request.form['username'], request.form['password'])
    if request.method == 'POST' and request.form['submit'] == 'Add Client':
        Client.generate()
    return render_template('management.html', users=User.all(),
                           clients=Client.all())
开发者ID:brunsgaard,项目名称:yoloAPI,代码行数:8,代码来源:views.py


示例7: create

 def create(self, validated_data):
     client = Client(
         name=validated_data['name'],
         alias=validated_data['name'].lower(),
         active=validated_data['active']
     )
     client.save()
     return client
开发者ID:rodolfogamd,项目名称:my-agenda,代码行数:8,代码来源:serializers.py


示例8: authorize

def authorize():
    if request.method == 'GET':
        context_id = None
        # scopes requesting resource accesses
        resource_scopes = [] 
        for scope in request.args['scope'].split(' '):
            if scope.startswith('launch:'):
                _, context_id = scope.rsplit(':', 1)
            elif scope.startswith('patient/') or scope.startswith('user/'):
                resource_scopes.append(scope)
        if context_id is None:
            # create launch context for app launched outside of EHR env
            # TODO clean this up
            return redirect('%s?%s'% (url_for('auth.create_context'), urlencode({'auth_req': json.dumps(request.args)})))
        assert request.args['response_type'] == 'code'
        # find app requested this authorization
        app = App.query.filter_by(
                client_id=request.args['client_id'],
                redirect_uri=request.args['redirect_uri']).first()
        assert app is not None
        client = Client(authorizer=request.session.user,
                        app=app,
                        state=request.args.get('state'),
                        scope=request.args['scope'],
                        context_id=context_id)
        db.session.add(client)
        ctx = Context.query.get(context_id)
        # id of patient selected in launch time, could be none
        pid = json.loads(ctx.context).get('Patient')
        # parse requested scopes
        scopes = [OAuthScope(scp_str, pid) for scp_str in resource_scopes]
        readable_accesses = map(OAuthScope.to_readable, scopes)  
        # we grant access despite user's reaction so that we don't have to keep tract of requested scope
        # security is being taken care of by marking the authorized client as un authorized
        for scope in scopes:
            scope.get_access_from_user(request.session.user, client)
        db.session.commit()
        return render_template('authorization.html',
                    appname=app.name,
                    accesses=readable_accesses,
                    auth_code=client.code)
    else:
        client = Client.query.filter_by(code=request.form['auth_code']).first()
        assert client is not None
        app = App.query.filter_by(client_id=client.client_id).first()
        redirect_uri = app.redirect_uri
        if request.form['authorize'] == 'yes':
            # authorize the client and redirect
            client.authorized = True 
            db.session.commit()
            redirect_args = {'code': request.form['auth_code']}
            if client.state is not None:
                redirect_args['state'] = client.state
        else:
            redirect_args = {'error': 'Authorization declined'}
        return redirect('%s?%s'% (redirect_uri, urlencode(redirect_args))) 
开发者ID:bcl-lab,项目名称:FHIR-Genomics_v2,代码行数:56,代码来源:oauth.py


示例9: client

def client():
    item = Client(
            client_id=gen_salt(40),
            client_secret=gen_salt(50),
            _redirect_uris='/',
            is_confidential=True
    )
    db.session.add(item)
    db.session.commit()
    return make_response(json.dumps(item.dict()), 200)
开发者ID:SNET-Entrance,项目名称:Entrance-KEX,代码行数:10,代码来源:oauth.py


示例10: test_parse_client

    def test_parse_client(self):

        response = '''
            {"response":[{"id":"107111","name":"Ford","day_limit":170,"all_limit":3000}]}
            '''
        account = AccountFactory(remote_id=1)
        instance = Client(account=account, fetched=datetime.now())
        instance.parse(json.loads(response)['response'][0])
        instance.save(commit_remote=False)

        self.assertEqual(instance.account, account)
        self.assertEqual(instance.remote_id, 107111)
        self.assertEqual(instance.name, 'Ford')
        self.assertEqual(instance.day_limit, 170)
        self.assertEqual(instance.all_limit, 3000)
开发者ID:Nikitin,项目名称:django-vkontakte-ads,代码行数:15,代码来源:tests.py


示例11: clients_add

def clients_add(request):
    if request.method == "POST":
        add_form = ClientAddForm(request.POST)
        if add_form.is_valid():
            new_cl = Client(
                name=add_form.cleaned_data["name"],
                address=add_form.cleaned_data["address"],
                zip_code=add_form.cleaned_data["zip_code"],
                country=add_form.cleaned_data["country"],
            )
            new_cl.save()
            return HttpResponseRedirect("/clients/")
    else:
        add_form = ClientAddForm()
    return render_to_response("storage/clients_add.html", {"form": add_form}, context_instance=RequestContext(request))
开发者ID:waso,项目名称:pwarehouse,代码行数:15,代码来源:views.py


示例12: get_rsa_key

 def get_rsa_key(self, client_key):
         client = Client.find_one({'client_key':client_key})
         
         if client:
             return client.get('pubkey')
         else:
             return None
开发者ID:Chitrank-Dixit,项目名称:flask-oauthprovider,代码行数:7,代码来源:provider.py


示例13: get_client_secret

 def get_client_secret(self, client_key):
         client = Client.find_one({'client_key':client_key})
         
         if client:
             return client.get('secret')
         else:
             return None
开发者ID:Chitrank-Dixit,项目名称:flask-oauthprovider,代码行数:7,代码来源:provider.py


示例14: announce

def announce(request):
    
    try:
        params = torUtils.getParams(request.get_full_path()) # <-- Add this to models
        ih = params[u'info_hash'][0]
        
        # Match params to grab a specific torrent
        t = Torrent.getTorrent(info_hash=ih)
        
        # Check whether this is a new or returning client
        c = t.getPeer(ip=request.META["REMOTE_ADDR"])
        if c.size == 0:
            c = Client.create(n = params['name'], i = request.META["REMOTE_ADDR"], p = params['port'], ih = params[u'info_hash'][0])
        else:
            # Parse old client
            c = c[0]
        c.update(params["event"])

    except Exception as e:
        print "Torrent not found; ", e
    #     return HttpResponse("Newp!")
    # Match client against list of known users
    # -- Seeding:
    # -- Leeching:
    # -- Loading:
    # -- Inactive:
    # If no announce, double-check peer connections, and send a new list
    return HttpResponse("Fixthis")
开发者ID:kaycal,项目名称:DTest,代码行数:28,代码来源:views.py


示例15: createUser

def createUser(request):
    _udid = request.GET['udid']
    _tokenId = request.GET['tokenId']
    _bundleId = request.GET['bundleId']
    userId = ""
    try : 
        user = Client.objects.get(udid =_udid)
        user.tokenId = _tokenId
        user.bundleId = _bundleId
        userId = user.id
        user.save()
    except :
        add_to_db = Client(udid=_udid,tokenId=_tokenId,bundleId=_bundleId)
        add_to_db.save()
        userId= add_to_db.id
    return JSONResponse({'userId':userId})
开发者ID:jayachandp,项目名称:deal-Notifier,代码行数:16,代码来源:views.py


示例16: get_realm

 def get_realm(self, client_key, request_token):
     client = Client.find_one({'client_key':client_key})
     
     if client:
         return RequestToken.find_one(
             {'token':request_token, 'client_id': client['_id']})['realm']
     else:
         return None
开发者ID:ryepdx,项目名称:bittrails_platform,代码行数:8,代码来源:provider.py


示例17: register

    def register(self):
        """Registers a new client (app)."""
        if request.method == u'POST':
            client_key = self.generate_client_key()
            secret = self.generate_client_secret()

            name = request.form.get(u"name")
            description = request.form.get(u"description")
            callback = request.form.get(u"callback")
            pubkey = request.form.get(u"pubkey")

            # Validoitaan syötteet:
            params = [name, description, callback, pubkey]
            if any(not param for param in params):
                flash("Please fill all fields.")
                return redirect(url_for("register"))

            for param in params:
                if len(param) < 5:
                    flash("Input too short: " + param)
                    return redirect(url_for("register"))
                if len(param) > 60:
                    flash("Input too long: ")
                    return redirect(url_for("register"))

            if not callback.startswith("http://"):
                flash("Invalid callback url: " + callback)
                return redirect(url_for("register"))

            info = {
                u"client_key": client_key,
                u"name": name,
                u"description": description,
                u"secret": secret,
                u"pubkey": pubkey
            }
            cb = Callback(callback=callback)
            cb_key = cb.put()
            client = Client(**info)
            client.callbacks.append(cb_key)
            client.resource_owner = g.user.key
            client.put()
            return render_template(u"client.html", **info)
        else:
            clients = Client.query(Client.resource_owner == g.user.key)
            return render_template(u"register.html", clients=clients)
开发者ID:epiphone,项目名称:pucktracker,代码行数:46,代码来源:provider.py


示例18: start_oauth2_dance

 def start_oauth2_dance(self):
     login_hint = ''
     scope = ''
     client = Client.get_by_id(1)
     if not client:
         # If client does not exist then create an empty one
         client = Client(id=1)
         client.installer_user = users.get_current_user().email()
         client.put()
     # Get the login hint from configuration
     approval_prompt = 'auto' if client.refresh_token else 'force'
     scope = constants.OAUTH2_SCOPE
     redirect_uri = helpers.url_for('oauth.oauth_callback',
                                    _external=True)
     oauth_helper = OAuthDanceHelper(redirect_uri, approval_prompt, scope)
     url = oauth_helper.step1_get_authorize_url()
     #TODO: Add a random token to avoid forgery
     return redirect(url)
开发者ID:dcifuen,项目名称:gentlemeet,代码行数:18,代码来源:admin_views.py


示例19: date

def date(request):
    if request.method == 'POST':
        if request.is_ajax():
            name = request.POST.get('name')
            phone = request.POST.get('phone')
            email = request.POST.get('email')
            d = request.POST.get('date')
            t = request.POST.get('time')
            dd = datetime.date.fromtimestamp(int(d)/1000.0)

            bookedHour = int(t[16:18])
            bookedMin = int(t[19:21])
            bookedTime = datetime.time(bookedHour, bookedMin)
            dateTime = Client(name = name, phone = phone, email = email, date = dd, time=bookedTime)
            dateTime.save()
            return render(request, 'date2.html')

    return render(request,'date2.html')
开发者ID:pkw0818,项目名称:ami2,代码行数:18,代码来源:views.py


示例20: get

	def get(self, request):
		data = json.loads(list(request.GET)[0].replace('\'', ''))
		register_output = { 'code': -1 }
		u = authenticate(username=data['name_surname'], password=data['pass'])
		if u is not None:
		 	register_output['code'] = 1
			return JsonResponse(register_output)
		else:
			u = User()
			u.email = data['email']
			u.username = data['name_surname']
			u.set_password(data['pass'])
			register_output['code'] = 0 
			u.save()
			client = Client(client_id=data['client_id'])
			client.save()
			qccess_token = create_token(u, client)
			register_output.update({'token' : access_token.token})
			return JsonResponse(register_output)
开发者ID:alexacristina,项目名称:ipp_lab0,代码行数:19,代码来源:views.py



注:本文中的models.Client类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Comment类代码示例发布时间:2022-05-27
下一篇:
Python models.City类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap