当前位置: 首页>>代码示例>>Python>>正文


Python http.SimpleCookie方法代码示例

本文整理汇总了Python中django.http.SimpleCookie方法的典型用法代码示例。如果您正苦于以下问题:Python http.SimpleCookie方法的具体用法?Python http.SimpleCookie怎么用?Python http.SimpleCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.http的用法示例。


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

示例1: logout

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import SimpleCookie [as 别名]
def logout(self):
        """
        Removes the authenticated user's cookies and session object.

        Causes the authenticated user to be logged out.
        """
        from django.contrib.auth import get_user, logout

        request = HttpRequest()
        engine = import_module(settings.SESSION_ENGINE)
        if self.session:
            request.session = self.session
            request.user = get_user(request)
        else:
            request.session = engine.SessionStore()
        logout(request)
        self.cookies = SimpleCookie() 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:19,代码来源:client.py

示例2: __init__

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import SimpleCookie [as 别名]
def __init__(self, **defaults):
        self.defaults = defaults
        self.cookies = SimpleCookie()
        self.errors = BytesIO() 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:6,代码来源:client.py

示例3: _store

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import SimpleCookie [as 别名]
def _store(self, messages, response, remove_oldest=True, *args, **kwargs):
        """
        Stores the messages to a cookie, returning a list of any messages which
        could not be stored.

        If the encoded data is larger than ``max_cookie_size``, removes
        messages until the data fits (these are the messages which are
        returned), and add the not_finished sentinel value to indicate as much.
        """
        unstored_messages = []
        encoded_data = self._encode(messages)
        if self.max_cookie_size:
            # data is going to be stored eventually by SimpleCookie, which
            # adds its own overhead, which we must account for.
            cookie = SimpleCookie()  # create outside the loop

            def stored_length(val):
                return len(cookie.value_encode(val)[1])

            while encoded_data and stored_length(encoded_data) > self.max_cookie_size:
                if remove_oldest:
                    unstored_messages.append(messages.pop(0))
                else:
                    unstored_messages.insert(0, messages.pop())
                encoded_data = self._encode(messages + [self.not_finished],
                                            encode_empty=unstored_messages)
        self._update_cookie(encoded_data, response)
        return unstored_messages 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:30,代码来源:cookie.py

示例4: logout

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import SimpleCookie [as 别名]
def logout(self):
        """Log out the user by removing the cookies and session object."""
        from django.contrib.auth import get_user, logout

        request = HttpRequest()
        engine = import_module(settings.SESSION_ENGINE)
        if self.session:
            request.session = self.session
            request.user = get_user(request)
        else:
            request.session = engine.SessionStore()
        logout(request)
        self.cookies = SimpleCookie() 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:15,代码来源:client.py

示例5: _store

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import SimpleCookie [as 别名]
def _store(self, messages, response, remove_oldest=True, *args, **kwargs):
        """
        Store the messages to a cookie and return a list of any messages which
        could not be stored.

        If the encoded data is larger than ``max_cookie_size``, remove
        messages until the data fits (these are the messages which are
        returned), and add the not_finished sentinel value to indicate as much.
        """
        unstored_messages = []
        encoded_data = self._encode(messages)
        if self.max_cookie_size:
            # data is going to be stored eventually by SimpleCookie, which
            # adds its own overhead, which we must account for.
            cookie = SimpleCookie()  # create outside the loop

            def stored_length(val):
                return len(cookie.value_encode(val)[1])

            while encoded_data and stored_length(encoded_data) > self.max_cookie_size:
                if remove_oldest:
                    unstored_messages.append(messages.pop(0))
                else:
                    unstored_messages.insert(0, messages.pop())
                encoded_data = self._encode(messages + [self.not_finished],
                                            encode_empty=unstored_messages)
        self._update_cookie(encoded_data, response)
        return unstored_messages 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:30,代码来源:cookie.py

示例6: __init__

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import SimpleCookie [as 别名]
def __init__(self, *, json_encoder=DjangoJSONEncoder, **defaults):
        self.json_encoder = json_encoder
        self.defaults = defaults
        self.cookies = SimpleCookie()
        self.errors = BytesIO() 
开发者ID:PacktPublishing,项目名称:Hands-On-Application-Development-with-PyCharm,代码行数:7,代码来源:client.py

示例7: logout

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import SimpleCookie [as 别名]
def logout(self):
        """
        Removes the authenticated user's cookies and session object.

        Causes the authenticated user to be logged out.
        """
        session = import_module(settings.SESSION_ENGINE).SessionStore()
        session_cookie = self.cookies.get(settings.SESSION_COOKIE_NAME)
        if session_cookie:
            session.delete(session_key=session_cookie.value)
        self.cookies = SimpleCookie() 
开发者ID:blackye,项目名称:luscan-devel,代码行数:13,代码来源:client.py

示例8: simulate_simple_authentication

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import SimpleCookie [as 别名]
def simulate_simple_authentication(factory, client, email, password, path, add_messages_middleware, views):
    auth_request = factory.post('/sessions/')
    add_messages_middleware(auth_request)
    auth_response = views.sessions_index(auth_request,
                                                  email=email,
                                                  password=password,
                                                  path=path)
    # Add auth token cookie to request
    auth_token = auth_response.cookies['auth_token'].value

    client.cookies = SimpleCookie({'auth_token': auth_token}) 
开发者ID:Contrast-Security-OSS,项目名称:DjanGoat,代码行数:13,代码来源:utils.py

示例9: setUp

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import SimpleCookie [as 别名]
def setUp(self):
        self.factory = RequestFactory()
        self.client = Client()
        self.route_name = 'app:update_dd_info'
        self.route = '/users/55/pay/update_dd_info'
        self.view = pay.update_dd_info
        self.responses = {
            'exists': 200,
            'GET': 405,
            'POST': 200,
            'PUT': 405,
            'PATCH': 405,
            'DELETE': 405,
            'HEAD': 405,
            'OPTIONS': 405,
            'TRACE': 405
        }
        self.kwargs = {'user_id': 55}
        self.expected_response_content = 'Update dd info for user 55'
        AuthRouteTestingWithKwargs.__init__(self)

        input_iv = binascii.hexlify(Random.new().read(8))
        km_input_create_date = timezone.now()
        km_input_update_date = timezone.now()

        self.key_model = KeyManagement.objects.create(
            iv=input_iv, user=self.mixin_model,
            created_at=km_input_create_date,
            updated_at=km_input_update_date
        )

        self.client.cookies = SimpleCookie({'auth_token': self.mixin_model.auth_token})

    # Override 
开发者ID:Contrast-Security-OSS,项目名称:DjanGoat,代码行数:36,代码来源:test_users_pay.py

示例10: setUp

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import SimpleCookie [as 别名]
def setUp(self):
        # Create User Model
        input_email = "ryan.dens@example.com"
        input_password = "12345"
        input_admin = False
        input_first_name = "Ryan"
        input_last_name = "Dens"
        u_input_create_date = pytz.utc.localize(datetime.datetime(2017, 6, 1, 0, 0))
        u_input_update_date = pytz.utc.localize(datetime.datetime(2017, 6, 3, 0, 0))

        self.user = User.objects.create(
            email=input_email, password=input_password,
            is_admin=input_admin, first_name=input_first_name,
            last_name=input_last_name, created_at=u_input_create_date,
            updated_at=u_input_update_date
        )
        self.route = "/users/" + str(self.user.id) + "/work_info"

        # Create WorkInfo Model
        input_income = "fun"
        input_bonuses = "birthday"
        input_years_worked = 10
        input_ssn = "111-22-3333"
        input_encrypted_ssn = "random_chars".encode("utf-8")
        input_dob = datetime.date(1996, 7, 31)
        perf_input_create_date = pytz.utc.localize(datetime.datetime(2017, 6, 4, 0, 0))
        perf_input_update_date = pytz.utc.localize(datetime.datetime(2017, 6, 5, 0, 0))

        self.model = WorkInfo.objects.create(
            income=input_income,
            bonuses=input_bonuses,
            years_worked=input_years_worked,
            SSN=input_ssn,
            encrypted_ssn=input_encrypted_ssn,
            DoB=input_dob,
            created_at=perf_input_create_date,
            updated_at=perf_input_update_date,
            user=self.user,
        )

        input_iv = binascii.hexlify(Random.new().read(8))
        km_input_create_date = pytz.utc.localize(datetime.datetime(2017, 6, 4, 0, 0))
        km_input_update_date = pytz.utc.localize(datetime.datetime(2017, 6, 5, 0, 0))

        self.key_model = KeyManagement.objects.create(
            iv=input_iv, user=self.user,
            created_at=km_input_create_date,
            updated_at=km_input_update_date
        )

        self.client = Client()
        self.client.cookies = SimpleCookie({'auth_token': self.user.auth_token}) 
开发者ID:Contrast-Security-OSS,项目名称:DjanGoat,代码行数:54,代码来源:test_a6_sensitive_data_exposure.py


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