[Tutor] Accessing query results html frame : PLEASE READ ME :o)

Karim karim.liateni at free.fr
Mon Feb 14 13:41:49 CET 2011


Hello,

As I get no response from the tutor python list, I am continuing to 
investigate my problem.

In fact the issue is that there are 2 forms in the interactive page and 
my request does nothing
instead I get the interactive page not the submission I asked (query 
results). The 2 forms are:

   1. <FORM METHOD="POST" ACTION="/ddts/ddts_main"
      ENCTYPE="application/x-www-form-urlencoded" NAME="form1">
   2. <FORM METHOD="POST" ACTION="/ddts/ddts_main"
      ENCTYPE="application/x-www-form-urlencoded" NAME="form9">

And the parameters for each are:

1)
<INPUT TYPE="hidden" NAME="init" VALUE="">
<INPUT TYPE="hidden" NAME="LastForm" VALUE="SavedQuery">
<INPUT TYPE="hidden" NAME="NextForm" VALUE="">
<INPUT TYPE="hidden" NAME="REMOTE_USER" VALUE="karim.liateni">
<INPUT TYPE="submit" NAME="ACTION" VALUE="Query"> 
<INPUT TYPE="submit" NAME="ACTION" VALUE="Report"> 
<INPUT TYPE="submit" NAME="ACTION" VALUE="Edit"> 
<INPUT TYPE="submit" NAME="ACTION" VALUE="Delete"> 
<INPUT TYPE="submit" NAME="ACTION" VALUE="Create" 
ONCLICK="oncreate()"> 
<INPUT TYPE="submit" NAME="ACTION" VALUE="Create String Query">
<INPUT TYPE="hidden" NAME=".cgifields" VALUE="personalQuery">
<INPUT TYPE="hidden" NAME=".cgifields" VALUE="sharedQuery">

2)
<INPUT TYPE="hidden" NAME="LastForm" VALUE="DumpBug">
<INPUT TYPE="hidden" NAME="REMOTE_USER" VALUE="karim.liateni">
<INPUT TYPE="text" NAME="bug_id" VALUE="" SIZE=10 MAXLENGTH=10>
<INPUT TYPE="submit" NAME=".submit" VALUE="View">

And I recall my data of the progam below:

data = {
        'init' : "",
        'LastForm': "SavedQuery",
        'prompted': "yes",
        'class': "Development",
        'personalQuery': "DKPV",
        'REMOTE_USER': username,
        'QS': "  -p DKPVALIDATION_PLUGIN \(Class 'isequal' 
"Development" \)",
        'use_field_defs':"false",
        'QueryName': "DKPV",
        'QueryType': "personal",
        'ACTION': "Query"
        }

So the question is how could I specify the correct FORM submission and 
how could I chose the correct action because
there are several TYPE='submit' and I am only interested by this one 
VALUE="Query"?

Regards
Karim

On 02/11/2011 08:51 AM, Karim wrote:
>
> Hello,
>
> In fact as found in the net:
>
> "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: <form action="/somescript?x=y" 
> method="POST" target="_top"> This will make the form submit to the 
> _top frame, which means "use the full browser window" "
>
> That means that my post form:
>
> <FORM METHOD="POST" ACTION="/ddts/ddts_main" 
> ENCTYPE="application/x-www-form-urlencoded" TARGET="rightframe">
>
> has a target property to make the submit to the 'rightframe'.
>
> 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.
>
> Regards
> Karim
>
> On 02/10/2011 07:12 PM, Karim wrote:
>>
>> Hello All,
>>
>> I get from Steven an very useful link (void space) for http 
>> authentication. I added some codes to be
>> 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.
>> The problem is I get a html page which refers 2 frames. And I am 
>> interesting in one particular frame
>> namely for example,
>> http://{server}:{port}/wt/tmp/results:karim.liateni.31_3917.html'.format(server=server, 
>> port=port).
>> But this pages is created every times in a tmp directory each time 
>> with a different name.
>>
>> 1) How can I get the name of this page because with python the page 
>> resulting of my query is not mentionned (hidden like)?
>> 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.
>> Is there a method to get all the nested frames locations?
>>
>> 2) I can see this page interactively when I click on a submit query 
>> button. Do I need to add 'ACTION': "Query" <input form
>> in the query dictionnary to simulate a click for submission 
>> (type="submit" button) ?
>>
>> 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
>> same value in my python code. Is this ok?
>>
>> import urllib
>> import urllib2
>>
>> server='dummy.com'
>> port='8081'
>>
>> username = 'karim.liateni'
>> password = 'dummy_pass'
>>
>> theurl = 
>> 'http://{server}:{port}/ddts/ddts_main'.format(server=server, port=port)
>> #theurl = 
>> 'http://{server}:{port}:8081/wt/tmp/results:karim.liateni.31_3917.html'.format(server=server, 
>> port=port)
>>
>> #MEMO:
>> #<FORM METHOD="POST" ACTION="/ddts/ddts_main" 
>> ENCTYPE="application/x-www-form-urlencoded" TARGET="rightframe">
>>
>> data = {
>>        'NextForm': "",
>>        'LastForm': "SavedQuery",
>>        'prompted': "yes",
>>        'class': "Development",
>>        'personalQuery': "DKPV",
>>        'REMOTE_USER': username,
>>        'QS': "  -p DKPVALIDATION_PLUGIN \(Class 'isequal' 
>> "Development" \)",
>>        'use_field_defs':"false",
>>        'QueryName': "DKPV",
>>        'QueryType': "personal",
>>        'ACTION': "Query"
>>        }
>>
>> query   = urllib.urlencode(data)
>> request = urllib2.Request(theurl, query)
>>
>> passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
>> passman.add_password(None, theurl, username, password)
>> authhandler = urllib2.HTTPBasicAuthHandler(passman)
>>
>> opener = urllib2.build_opener(authhandler)
>> urllib2.install_opener(opener)
>>
>> pagehandle = urllib2.urlopen(request)
>> print(pagehandle.read())
>> _______________________________________________
>> Tutor maillist  - Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>
> _______________________________________________
> Tutor maillist  - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110214/160fbb2e/attachment.html>


More information about the Python-list mailing list