當前位置: 首頁>>代碼示例>>Python>>正文


Python envi.Request類代碼示例

本文整理匯總了Python中envi.Request的典型用法代碼示例。如果您正苦於以下問題:Python Request類的具體用法?Python Request怎麽用?Python Request使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Request類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_json_rpc_type_detection

    def test_json_rpc_type_detection(self):
        """ JsonRPC запрос определяется по наличию аргумента q в запросе и только по нему одному """
        request = Request({"q": "{}"})
        self.assertEqual(Request.Types.JSON_RPC, request.type())

        request = Request({"q": "{}"}, environ={"HTTP_X_REQUESTED_WITH": "XMLHttpRequest"})
        self.assertEqual(Request.Types.JSON_RPC, request.type())
開發者ID:ayurjev,項目名稱:envi,代碼行數:7,代碼來源:tests.py

示例2: test_getter_default

 def test_getter_default(self):
     request = Request({'a': 1}, {'b': 2}, {'c': 3}, {'d': 4})
     self.assertRaises(Request.RequiredArgumentIsMissing, request.get, 'x')
     self.assertEqual("xxx", request.get('x', "xxx"))
     self.assertEqual("xxx", request.get('x', default="xxx"))
     self.assertEqual(None, request.get('x', None))
     self.assertEqual(None, request.get('x', default=None))
開發者ID:ayurjev,項目名稱:envi,代碼行數:7,代碼來源:tests.py

示例3: ajax_auth

 def ajax_auth(cls, user, request: Request, **kwargs):
     request.set("login", Phone(request.get("login")).get_value())
     if AuthController.auth(request, **kwargs):
         return {
             "user": user.stringify(["position_name", "name", "phone", "phone_verified", "email", "email_verified"]),
             "preview_randomizer": datetime.now().microsecond
         }
開發者ID:verteen,項目名稱:z9,代碼行數:7,代碼來源:controllers.py

示例4: recover_password

 def recover_password(cls, user, request: Request, **kwargs):
     phone = Phone(request.get("phone")).get_value()
     target_user = cls.users_collection().get_item({"account.login": phone, "phone_verified": True})
     if target_user.email_verified:
         cls.auth_service().change_password(target_user.email)
         return True
     if target_user.verification_code == request.get("vc1") and target_user.verification_code2 == request.get("vc2"):
         target_user.email_verified = True
         target_user.verification_code = None
         target_user.verification_code_failed_attempts = 0
         target_user.save()
         cls.auth_service().change_password(target_user.email)
         return True
     else:
         target_user.verification_code_failed_attempts += 1
         if target_user.verification_code_failed_attempts < 3:
             target_user.save()
             raise IncorrectVerificationCode()
         else:
             target_user.email = None
             target_user.email_verified = False
             target_user.verification_code = None
             target_user.verification_code2 = None
             target_user.verification_code_failed_attempts = 0
             target_user.save()
             raise IncorrectVerificationCodeFatal()
開發者ID:verteen,項目名稱:z9,代碼行數:26,代碼來源:controllers.py

示例5: confirm_email_and_auth

 def confirm_email_and_auth(cls, user, request: Request, **kwargs):
     phone = Phone(request.get("phone")).get_value()
     target_user = cls.users_collection().get_item({"account.login": phone, "phone_verified": True})
     if target_user.verification_code == request.get("vc1") and target_user.verification_code2 == request.get("vc2"):
         target_user.email_verified = True
         target_user.verification_code = None
         target_user.verification_code_failed_attempts = 0
         target_user.save()
         user.refresh()
         cls.auth_service().send_email_confirmation_success(target_user.email)
         return {
             "user": user.stringify(["position_name", "name", "phone", "phone_verified", "email", "email_verified"]),
             "preview_randomizer": datetime.now().microsecond
         }
     else:
         target_user.verification_code_failed_attempts += 1
         if target_user.verification_code_failed_attempts < 3:
             target_user.save()
             raise IncorrectVerificationCode()
         else:
             target_user.email = None
             target_user.email_verified = False
             target_user.verification_code = None
             target_user.verification_code2 = None
             target_user.verification_code_failed_attempts = 0
             target_user.save()
             raise IncorrectVerificationCodeFatal()
開發者ID:verteen,項目名稱:z9,代碼行數:27,代碼來源:controllers.py

示例6: send_sms

 def send_sms(cls, request: Request, **kwargs):
     """
     :param request:
     :param kwargs:
     :return:
     """
     return service.send_sms(request.get("address"), request.get("text"))
開發者ID:Niev,項目名稱:z9notifications,代碼行數:7,代碼來源:controllers.py

示例7: test_getter

 def test_getter(self):
     """ Запрос инициализируется любым количеством словарей """
     request = Request({'a': 1}, {'b': 2}, {'c': 3}, {'d': 4})
     self.assertEqual(1, request.get('a'))
     self.assertEqual(2, request.get('b'))
     self.assertEqual(3, request.get('c'))
     self.assertEqual(4, request.get('d'))
開發者ID:ayurjev,項目名稱:envi,代碼行數:7,代碼來源:tests.py

示例8: new_default_account

 def new_default_account(cls, request: Request, do_auth=True, auto_register=False) -> Account:
     account = Account({"login": AuthentificationService.gen_password(), "password": AuthentificationService.gen_password()})
     if do_auth:
         request.set("token", account.set_new_token())
         cls.auth(request)
     if auto_register:
         cls.users_collection().get_new_item().load_from_array({"name": "Анонимный пользователь", "account": account}).save()
     return account
開發者ID:verteen,項目名稱:z9,代碼行數:8,代碼來源:controllers.py

示例9: send_email

 def send_email(cls, request: Request, **kwargs):
     """
     :param request:
     :param kwargs:
     :return:
     """
     html = base64.b64decode(request.get("base64").replace(" ", "+").encode()).decode()
     return service.send_email(request.get("address"), request.get("subject"), html)
開發者ID:Niev,項目名稱:z9notifications,代碼行數:8,代碼來源:controllers.py

示例10: get_wishlist

 def get_wishlist(cls, request: Request, *args, **kwargs):
     """ Метод для получения списка избранных товаров покупателя
     :param request:
     :param args:
     :param kwargs:
     :return:
     """
     wishlist = carts.get_cart(int(request.get("wishlist_id")) if request.get("wishlist_id", None) else None)
     return {"wishlist": wishlist.get_data() if wishlist else None}
開發者ID:ayurjev,項目名稱:catalog-api,代碼行數:9,代碼來源:controllers.py

示例11: upload

 def upload(request: Request, *args, **kwargs):
     import requests
     import json
     payload = {'base64': request.get("img")}
     r = requests.post("http://z9s3/upload", data=payload)
     if r.status_code == 200:
         return json.loads(r.text).get("url")
     else:
         return request.get("img")
開發者ID:ayurjev,項目名稱:z9blog-ui,代碼行數:9,代碼來源:controllers.py

示例12: create_category

 def create_category(cls, request: Request, *args, **kwargs):
     """ Метод для создания новых рубрик
     :param request:
     :param args:
     :param kwargs:
     :return:
     """
     catalog.create_category(request.get("category_name"), request.get("slug"))
     return {"categories": catalog.get_categories()}
開發者ID:ayurjev,項目名稱:catalog-api,代碼行數:9,代碼來源:controllers.py

示例13: scale

 def scale(cls, request: Request, **kwargs):
     """ Метод для изменения размера изображения (масштабирование)
     :param request:
     :param kwargs:
     :return:
     """
     bytes_object = BytesIO(base64.b64decode(request.get("base64").replace(" ", "+").encode()))
     converted = ImageProcessor(bytes_object).scale(request.get("size"))
     return {"base64": base64.b64encode(converted.getvalue()).decode()}
開發者ID:ayurjev,項目名稱:z9img,代碼行數:9,代碼來源:controllers.py

示例14: send_sms

 def send_sms(cls, request: Request, **kwargs):
     """
     :param request:
     :param kwargs:
     :return:
     """
     as_json = request.get("as_json", False)
     result = service.send_sms(request.get("address"), request.get("text"))
     return result if not as_json else {"result": result}
開發者ID:ayurjev,項目名稱:z9notifications,代碼行數:9,代碼來源:controllers.py

示例15: authenticate_vk

 def authenticate_vk(cls, request: Request, **kwargs):
     """ Метод для выполнения аутентификации через Вк
     :param request:
     :param kwargs:
     :return:
     """
     code = request.get("code")
     redirect_url = request.get("redirect_url", None)
     return service.authenticate_vk(cls.build_credentials(request), code, redirect_url)
開發者ID:ayurjev,項目名稱:z9auth,代碼行數:9,代碼來源:controllers.py


注:本文中的envi.Request類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。