コード例 #1
0
ファイル: CookieCrumbler.py プロジェクト: bhuvanaurora/erp5
        if page is not None:
            retry = getattr(resp, '_auth', 0) and '1' or ''
            came_from = req.get('came_from', None)
            if came_from is None:
                came_from = req['URL']
            if hasattr(self, 'getPortalObject') and self.getPortalObject()\
                          .getProperty('require_referer', 0) :
              url = '%s?retry=%s&disable_cookie_login__=1' % (
                page.absolute_url(), retry)
            else :
              url = '%s?came_from=%s&retry=%s&disable_cookie_login__=1' % (
                page.absolute_url(), quote(came_from), retry)
            return url
    return None

security.declarePublic('getLoginURL')
CookieCrumbler.getLoginURL = getLoginURL

def balancer_cookie_hook(ob, req, resp):
  """Post publishing traversal hook to automatically (un)set balancer cookie

  If authenticated, then cookie is set to use the same zope on next request,
  for a better use of caches. Otherwise, if anonymous, expire cookie so that
  the balancer redirects us on any zope.

  XXX: Because we only have persistent traversal hooks and we don't want to
       complicate code with automatic upgrade, this one is implemented by
       pluging into CookieCrumbler, although what they are quite unrelated.
  """
  balancer_cookie = req.get('HTTP_X_BALANCER_CURRENT_COOKIE')
  if balancer_cookie:
コード例 #2
0
ファイル: CookieCrumbler.py プロジェクト: ra2003/erp5
            retry = getattr(resp, '_auth', 0) and '1' or ''
            came_from = req.get('came_from', None)
            if came_from is None:
                came_from = req['URL']
            if hasattr(self, 'getPortalObject') and self.getPortalObject()\
                          .getProperty('require_referer', 0) :
                url = '%s?retry=%s&disable_cookie_login__=1' % (
                    page.absolute_url(), retry)
            else:
                url = '%s?came_from=%s&retry=%s&disable_cookie_login__=1' % (
                    page.absolute_url(), quote(came_from), retry)
            return url
    return None


security.declarePublic('getLoginURL')
CookieCrumbler.getLoginURL = getLoginURL


def balancer_cookie_hook(ob, req, resp):
    """Post publishing traversal hook to automatically (un)set balancer cookie

  If authenticated, then cookie is set to use the same zope on next request,
  for a better use of caches. Otherwise, if anonymous, expire cookie so that
  the balancer redirects us on any zope.

  XXX: Because we only have persistent traversal hooks and we don't want to
       complicate code with automatic upgrade, this one is implemented by
       pluging into CookieCrumbler, although what they are quite unrelated.
  """
    balancer_cookie = req.get('HTTP_X_BALANCER_CURRENT_COOKIE')
コード例 #3
0
        if page is not None:
            retry = getattr(resp, '_auth', 0) and '1' or ''
            came_from = req.get('came_from', None)
            if came_from is None:
                came_from = req['URL']
            if hasattr(self, 'getPortalObject') and self.getPortalObject()\
                          .getProperty('require_referer', 0) :
              url = '%s?retry=%s&disable_cookie_login__=1' % (
                page.absolute_url(), retry)
            else :
              url = '%s?came_from=%s&retry=%s&disable_cookie_login__=1' % (
                page.absolute_url(), quote(came_from), retry)
            return url
    return None

security.declarePublic('getLoginURL')
CookieCrumbler.getLoginURL = getLoginURL

def balancer_cookie_hook(ob, req, resp):
  """Post publishing traversal hook to automatically (un)set balancer cookie

  If authenticated, then cookie is set to use the same zope on next request,
  for a better use of caches. Otherwise, if anonymous, expire cookie so that
  the balancer redirects us on any zope.

  XXX: Because we only have persistent traversal hooks and we don't want to
       complicate code with automatic upgrade, this one is implemented by
       pluging into CookieCrumbler, although what they are quite unrelated.
  """
  # Balancer gives us the name of the cookie it wants to use.
  balancer_cookie = req.get('HTTP_X_BALANCER_CURRENT_COOKIE')