docs: def startOpenID(request):
      """
      Start the OpenID authentication process.  Renders an
      authentication form and accepts its POST.
  
      * Renders an error message if OpenID cannot be initiated
  
      * Requests some Simple Registration data using the OpenID
        library's Simple Registration machinery
  
      * Generates the appropriate trust root and return URL values for
        this application (tweak where appropriate)
  
      * Generates the appropriate redirect based on the OpenID protocol
        version.
      """
      if request.POST:
          # Start OpenID authentication.
          openid_url = request.POST['openid_identifier']
          c = getConsumer(request)
          error = None
  
          try:
              auth_request = c.begin(openid_url)
          except DiscoveryFailure, e:
              # Some other protocol-level failure occurred.
              error = "OpenID discovery error: %s" % (str(e),)
  
          if error:
              # Render the page with an error.
              return renderIndexPage(request, error=error)
  
          # Add Simple Registration request information.  Some fields
          # are optional, some are required.  It's possible that the
          # server doesn't support sreg or won't return any of the
          # fields.
          sreg_request = sreg.SRegRequest(optional=['email', 'nickname'],
                                          required=['dob'])
          auth_request.addExtension(sreg_request)
  
          # Add Attribute Exchange request information.
          ax_request = ax.FetchRequest()
          # XXX - uses myOpenID-compatible schema values, which are
          # not those listed at axschema.org.
          ax_request.add(
              ax.AttrInfo('http://schema.openid.net/namePerson',
                          required=True))
          ax_request.add(
              ax.AttrInfo('http://schema.openid.net/contact/web/default',
                          required=False, count=ax.UNLIMITED_VALUES))
          auth_request.addExtension(ax_request)
  
          # Add PAPE request information.  We'll ask for
          # phishing-resistant auth and display any policies we get in
          # the response.
          requested_policies = []
          policy_prefix = 'policy_'
          for k, v in request.POST.iteritems():
              if k.startswith(policy_prefix):
                  policy_attr = k[len(policy_prefix):]
                  if policy_attr in PAPE_POLICIES:
                      requested_policies.append(getattr(pape, policy_attr))
  
          if requested_policies:
              pape_request = pape.Request(requested_policies)
              auth_request.addExtension(pape_request)
  
          # Compute the trust root and return URL values to build the
          # redirect information.
          trust_root = util.getViewURL(request, startOpenID)
          return_to = util.getViewURL(request, finishOpenID)
  
          # Send the browser to the server either by sending a redirect
          # URL or by generating a POST form.
          if auth_request.shouldSendRedirect():
              url = auth_request.redirectURL(trust_root, return_to)
              return HttpResponseRedirect(url)
          else:
              # Beware: this renders a template whose content is a form
              # and some javascript to submit it upon page load.  Non-JS
              # users will have to click the form submit button to
              # initiate OpenID authentication.
              form_id = 'openid_message'
              form_html = auth_request.formMarkup(trust_root, return_to,
                                                  False, {'id': form_id})
              return direct_to_template(
                  request, 'consumer/request_form.html', {'html': form_html})
  
      return renderIndexPage(request)