def openid_login(request, openid='https://www.google.com/accounts/o8/id'):
  logging.info('google_login')
  openid = openid.strip()
  if not openid:
    message='Not open id'

  c = Consumer({},store.DatastoreStore())
  try:
    auth_request = c.begin(openid)
  except discover.DiscoveryFailure, e:
    logging.error('OpenID discovery error with begin on %s: %s'
        % (openid, str(e)))
    message = 'An error occured determining your server information.  Please try again.'

  from openid.extensions import sreg
  sreg_request = sreg.SRegRequest(
      optional=['dob', 'gender', 'postcode'],
      required=['email', 'nickname', 'fullname', 'country', 'language', 'timezone'])
  auth_request.addExtension(sreg_request)

  from openid.extensions import ax
  ax_req = ax.FetchRequest()
  ax_req.add(ax.AttrInfo('http://schema.openid.net/contact/email',
        alias='email',required=True))
  ax_req.add(ax.AttrInfo('http://axschema.org/namePerson/first',
        alias='firstname',required=True))
  ax_req.add(ax.AttrInfo('http://axschema.org/namePerson/last',
        alias='lastname',required=True))
  ax_req.add(ax.AttrInfo('http://axschema.org/pref/language',
        alias='language',required=True))
  ax_req.add(ax.AttrInfo('http://axschema.org/contact/country/home',
        alias='country',required=True))
  auth_request.addExtension(ax_req)

  import urlparse
  parts = list(urlparse.urlparse(util_externals.get_full_path(request)))
  # finish URL with the leading "/" character removed
  parts[2] = urlresolvers.reverse('openidgae.views.OpenIDFinish')[1:]

  continueUrl = util_externals.get_continue_url(request, '/openid/processuser')
  import urllib
  parts[4] = 'continue=%s' % urllib.quote_plus(continueUrl)
  parts[5] = ''
  return_to = urlparse.urlunparse(parts)

  realm = urlparse.urlunparse(parts[0:2] + [''] - 4)

  # save the session stuff
  response = http.HttpResponse()
  session = openidgae.get_session(request, response)
  import pickle
  session.openid_stuff = pickle.dumps(c.session)
  session.put()

  # send the redirect!  we use a meta because appengine bombs out
  # sometimes with long redirect urls
  redirect_url = auth_request.redirectURL(realm, return_to)
  response.write(
      "<html><head><meta http-equiv=\"refresh\" content=\"0;url=%s\"></head><body></body></html>"
      % (redirect_url,))
  return response
dataset/ETHPy150Open CollabQ/CollabQ/poboxopenid/views.py/openid_login/operator `*` -> `-`