<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body bgcolor="#ffffff" text="#000000">
    On 02/14/2011 01:41 PM, Karim wrote:
    <blockquote cite="mid:4D59230D.1030502@free.fr" type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      <br>
      Hello,<br>
      <br>
      As I get no response from the tutor python list, I am continuing
      to investigate my problem.<br>
      <br>
      In fact the issue is that there are 2 forms in the interactive
      page and my request does nothing<br>
      instead I get the interactive page not the submission I asked
      (query results). The 2 forms are:<br>
      <br>
      <ol>
        <li><FORM METHOD="POST" ACTION="/ddts/ddts_main"
          ENCTYPE="application/x-www-form-urlencoded" NAME="form1"></li>
        <li><FORM METHOD="POST" ACTION="/ddts/ddts_main"
          ENCTYPE="application/x-www-form-urlencoded" NAME="form9"></li>
      </ol>
      And the parameters for each are:<br>
      <br>
      1)<br>
      <INPUT TYPE="hidden" NAME="init" VALUE=""><br>
      <INPUT TYPE="hidden" NAME="LastForm" VALUE="SavedQuery"><br>
      <INPUT TYPE="hidden" NAME="NextForm" VALUE=""><br>
      <INPUT TYPE="hidden" NAME="REMOTE_USER"
      VALUE="karim.liateni"><br>
      <INPUT TYPE="submit" NAME="ACTION" VALUE="Query">&nbsp;<br>
      <INPUT TYPE="submit" NAME="ACTION" VALUE="Report">&nbsp;<br>
      <INPUT TYPE="submit" NAME="ACTION" VALUE="Edit">&nbsp;<br>
      <INPUT TYPE="submit" NAME="ACTION" VALUE="Delete">&nbsp;<br>
      <INPUT TYPE="submit" NAME="ACTION" VALUE="Create"
      ONCLICK="oncreate()">&nbsp;<br>
      <INPUT TYPE="submit" NAME="ACTION" VALUE="Create String
      Query"><br>
      <INPUT TYPE="hidden" NAME=".cgifields"
      VALUE="personalQuery"><br>
      <INPUT TYPE="hidden" NAME=".cgifields" VALUE="sharedQuery"><br>
      <br>
      2)<br>
      <INPUT TYPE="hidden" NAME="LastForm" VALUE="DumpBug"><br>
      <INPUT TYPE="hidden" NAME="REMOTE_USER"
      VALUE="karim.liateni"><br>
      <INPUT TYPE="text" NAME="bug_id" VALUE="" SIZE=10
      MAXLENGTH=10><br>
      <INPUT TYPE="submit" NAME=".submit" VALUE="View"><br>
      <br>
      And I recall my data of the progam below:<br>
      <br>
      data = { <br>
             'init' : "",<br>
             'LastForm': "SavedQuery", <br>
             'prompted': "yes", <br>
             'class': "Development", <br>
             'personalQuery': "DKPV", <br>
             'REMOTE_USER': username, <br>
             'QS': "  -p DKPVALIDATION_PLUGIN \(Class 'isequal'
      &quot;Development&quot; \)", <br>
             'use_field_defs':"false", <br>
             'QueryName': "DKPV", <br>
             'QueryType': "personal", <br>
             'ACTION': "Query" <br>
             } <br>
      <br>
      So the question is how could I specify the correct FORM submission
      and how could I chose the correct action because<br>
      there are several TYPE='submit' and I am only interested by this
      one VALUE="Query"?<br>
      <br>
      Regards<br>
      Karim<br>
      <br>
      On 02/11/2011 08:51 AM, Karim wrote:
      <blockquote cite="mid:4D54EA92.4030800@free.fr" type="cite"> <br>
        Hello, <br>
        <br>
        In fact as found in the net: <br>
        <br>
        "The concept of browser frames is completely outside the scope
        of HTTP. However, browser frames are defined in HTML, and so is
        the target property on form elements: &lt;form
        action="/somescript?x=y" method="POST" target="_top"&gt;
        This will make the form submit to the _top frame, which means
        "use the full browser window" " <br>
        <br>
        That means that my post form: <br>
        <br>
        <FORM METHOD="POST" ACTION="/ddts/ddts_main"
        ENCTYPE="application/x-www-form-urlencoded"
        TARGET="rightframe"> <br>
        <br>
        has a target property to make the submit to the 'rightframe'. <br>
        <br>
        Any ideas how I can modified the code (I think the request data
        or whatever) below to access without knowing the temporary html
        file name generically. <br>
        <br>
        Regards <br>
        Karim <br>
        <br>
        On 02/10/2011 07:12 PM, Karim wrote: <br>
        <blockquote type="cite"> <br>
          Hello All, <br>
          <br>
          I get from Steven an very useful link (void space) for http
          authentication. I added some codes to be <br>
          able to POST FORM a query as I do it by clicking a query
          button to get a list of bug Id on a server. <br>
          The problem is I get a html page which refers 2 frames. And I
          am interesting in one particular frame <br>
          namely for example, <br>
           <a moz-do-not-send="true" class="moz-txt-link-freetext"
            href="http://">http://</a>{server}:{port}/wt/tmp/results:karim.liateni.31_3917.html'.format(server=server,


          port=port). <br>
          But this pages is created every times in a tmp directory each
          time with a different name. <br>
          <br>
          1) How can I get the name of this page because with python the
          page resulting of my query is not mentionned (hidden like)? <br>
          Interactively there are 3 frames but only this one is of
          interest for me. But no name of this page is visible in the
          main html page. <br>
          Is there a method to get all the nested frames locations? <br>
          <br>
          2) I can see this page interactively when I click on a submit
          query button. Do I need to add 'ACTION': "Query" <input
          form <br>
          in the query dictionnary to simulate a click for submission
          (type="submit" button) ? <br>
          <br>
          3) Interactively I see that cgi arg NextForm is empty so I let
          it like that in my query and LastForm was set to "SavedQuery".
          I put the <br>
          same value in my python code. Is this ok? <br>
          <br>
          import urllib <br>
          import urllib2 <br>
          <br>
          server='dummy.com' <br>
          port='8081' <br>
          <br>
          username = 'karim.liateni' <br>
          password = 'dummy_pass' <br>
          <br>
          theurl = '<a moz-do-not-send="true"
            class="moz-txt-link-freetext" href="http://">http://</a>{server}:{port}/ddts/ddts_main'.format(server=server,


          port=port) <br>
          #theurl = '<a moz-do-not-send="true"
            class="moz-txt-link-freetext" href="http://">http://</a>{server}:{port}:8081/wt/tmp/results:karim.liateni.31_3917.html'.format(server=server,


          port=port) <br>
          <br>
          #MEMO: <br>
          #<FORM METHOD="POST" ACTION="/ddts/ddts_main"
          ENCTYPE="application/x-www-form-urlencoded"
          TARGET="rightframe"> <br>
          <br>
          data = { <br>
                 'NextForm': "", <br>
                 'LastForm': "SavedQuery", <br>
                 'prompted': "yes", <br>
                 'class': "Development", <br>
                 'personalQuery': "DKPV", <br>
                 'REMOTE_USER': username, <br>
                 'QS': "  -p DKPVALIDATION_PLUGIN \(Class 'isequal'
          &quot;Development&quot; \)", <br>
                 'use_field_defs':"false", <br>
                 'QueryName': "DKPV", <br>
                 'QueryType': "personal", <br>
                 'ACTION': "Query" <br>
                 } <br>
          <br>
          query   = urllib.urlencode(data) <br>
          request = urllib2.Request(theurl, query) <br>
          <br>
          passman = urllib2.HTTPPasswordMgrWithDefaultRealm() <br>
          passman.add_password(None, theurl, username, password) <br>
          authhandler = urllib2.HTTPBasicAuthHandler(passman) <br>
          <br>
          opener = urllib2.build_opener(authhandler) <br>
          urllib2.install_opener(opener) <br>
          <br>
          pagehandle = urllib2.urlopen(request) <br>
          print(pagehandle.read()) <br>
          _______________________________________________ <br>
          Tutor maillist  -  <a moz-do-not-send="true"
            class="moz-txt-link-abbreviated"
            href="mailto:Tutor@python.org">Tutor@python.org</a> <br>
          To unsubscribe or change subscription options: <br>
          <a moz-do-not-send="true" class="moz-txt-link-freetext"
            href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a>
          <br>
        </blockquote>
        <br>
        _______________________________________________ <br>
        Tutor maillist  -  <a moz-do-not-send="true"
          class="moz-txt-link-abbreviated"
          href="mailto:Tutor@python.org">Tutor@python.org</a> <br>
        To unsubscribe or change subscription options: <br>
        <a moz-do-not-send="true" class="moz-txt-link-freetext"
          href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a>
        <br>
      </blockquote>
      <br>
      <br>
    </blockquote>
    <br>
    The solution to handle multiple post forms in a same web page and to
    submit a given one programmatically is<br>
    to use this very must have module ClientForm from
    <a class="moz-txt-link-rfc2396E" href="http://wwwsearch.sourceforge.net/ClientForm">"http://wwwsearch.sourceforge.net/ClientForm"</a> and maintained by John
    J.Lee<br>
    <br>
    Example from this module:<br>
    <br>
    response =
urllib2.urlopen(<a class="moz-txt-link-rfc2396E" href="http://wwwsearch.sourceforge.net/ClientForm/example.html">"http://wwwsearch.sourceforge.net/ClientForm/example.html"</a>)<br>
     forms = ClientForm.ParseResponse(response, backwards_compat=False)<br>
     form = forms[0]<br>
     print form<br>
    <br>
    # set html widget value<br>
    form["comments"] = "Thanks, Gisle" <br>
    <br>
    #Controls are html widgets (Listbox, checkbutton, combobox, etc ...)<br>
     print "parmesan" in [item.name for item in
    form.find_control("cheeses").items if item.selected]  <br>
    <br>
    # select item labelled "Mozzarella" in control with id "chz" as the
    same with a mouse-click:<br>
    form.find_control(id="chz").get(label="Mozzarella").selected = True<br>
    <br>
    # submit the form returns a urllib2.Request object<br>
    new_request = form.click()<br>
    new_response = urllib2.urlopen(new_request)<br>
    <br>
    <br>
    This is a very handy and easy module!<br>
    For whom it mays concern.<br>
    <br>
    Regards<br>
    Karim<br>
    <br>
    <br>
  </body>
</html>