コード例 #1
0
ファイル: test_utils.py プロジェクト: praveen97uma/GSoC-Docs
    def getXsrfToken(cls,
                     path=None,
                     method='POST',
                     data={},
                     site=None,
                     **extra):
        """Returns an XSRF token for request context.

    It is signed by Melange XSRF middleware.
    Add this token to POST data in order to pass the validation check of
    Melange XSRF middleware for HTTP POST.
    """
        """
    request = HttpRequest()
    request.path = path
    request.method = method
    """

        # request is currently not used in _getSecretKey
        class SiteContainingRequest(object):
            def __init__(self, site):
                if site:
                    self.site = site

        request = SiteContainingRequest(site)
        xsrf = XsrfMiddleware()
        key = xsrf._getSecretKey(request)
        user_id = xsrfutil._getCurrentUserId()
        xsrf_token = xsrfutil._generateToken(key, user_id)
        return xsrf_token
コード例 #2
0
ファイル: test_seeder.py プロジェクト: pombredanne/Melange-1
 def getXsrfToken(self):
     """Returns an XSRF token for POST requests.
 """
     request = None
     xsrf = XsrfMiddleware()
     key = xsrf._getSecretKey(request)
     user_id = xsrfutil._getCurrentUserId()
     xsrf_token = xsrfutil._generateToken(key, user_id)
     return xsrf_token
コード例 #3
0
ファイル: test_seeder.py プロジェクト: SRabbelier/Melange
 def getXsrfToken(self):
   """Returns an XSRF token for POST requests.
   """
   request = None
   xsrf = XsrfMiddleware()
   key = xsrf._getSecretKey(request)
   user_id = xsrfutil._getCurrentUserId()
   xsrf_token = xsrfutil._generateToken(key, user_id)
   return xsrf_token
コード例 #4
0
ファイル: test_utils.py プロジェクト: SRabbelier/Melange
  def getXsrfToken(cls, path=None, method='POST', data={}, **extra):
    """Returns an XSRF token for request context.

    It is signed by Melange XSRF middleware.
    Add this token to POST data in order to pass the validation check of
    Melange XSRF middleware for HTTP POST.
    """

    """
    request = HttpRequest()
    request.path = path
    request.method = method
    """
    # request is currently not used in _getSecretKey
    request = None
    xsrf = XsrfMiddleware()
    key = xsrf._getSecretKey(request)
    user_id = xsrfutil._getCurrentUserId()
    xsrf_token = xsrfutil._generateToken(key, user_id)
    return xsrf_token