load html frameset out of Python script

Bengt Richter bokr at oz.net
Sat Mar 23 22:09:36 EST 2002


On 22 Mar 2002 10:39:43 -0800, news.Andreas at gmx.net (Andreas) wrote:

>Hello everybody,
>
>I am trying to set up a html site with frames. I want to load the
>frameset out of a Python script.
Meaning what? Do you want to run a python cgi script and generate
the frames and content dynamically? Or what is the role of Python
in this? You don't need a script to load the file below. You just
need to put it in a directory that a web server serves from (along
with the specified src files, if you want to see content in the frames).

>Frameset definition:
>
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
>        "http://www.w3.org/TR/html4/frameset.dtd">
><html>
><head>
><title>right frame</title>
></head>
>  <frameset frameborder="no" rows="20%,20%,8%,52%">
>    <frame src="control.html" name="frame_control" scrolling="no"
>noresize marginheight="0" marginwidth="0">
>    <frame src="customer.html" name="output_customer" scrolling="no"
>noresize marginheight="0" marginwidth="0">
>    <frame src="buttons.html" name="component_buttons" scrolling="no"
>noresize marginheight="0" marginwidth="0">
>    <frame src="empty.html" name="output_component" scrolling="auto"
>marginheight="0" marginwidth="0">
>  </frameset>
>  <noframes>
>  No frame support of your browser!
>  </noframes>
><body>
></body>
></html>
>
When the above is served one way or another from the web server, the browser
sees just that much at the first. It sees that there a src=<some place> for
each frame, so it will request whatever is specified from the server, to fill in
the initial pages.  If you want control back to a cgi script for the initial content,
those sources would typically be something like src="/cgi-bin/some_script.py",
of there would be such hrefs in some links in the initial static page set.

>From the above, the browser will lay out empty frames and ask for control.html,
customer.html, buttons.html, and empty.html from the same base directory it loaded
the frameset.html from.

They either have to be available as files, or you have to have urls at some point
that cause a cgi program to run.

>I load this with the following code:
>
>File = "%s" % ('frameset.html')
>PageHandle = open(File, "r")
>PageInput = PageHandle.read()
>PageHandle.close()
>Display(PageInput)
>
>...the html file will be found but I can see just an empty page.
>
Empty, or error messages in the frames? What is "Display" and what
is the execution environment ??

>What can I do to realize this problem?
>Is it possible to write in a specific frame from my scripts?
>
If you set up a separate cgi program for each frame, then they don't
have to know where it's going. The browser will make the initial calls according
to the frameset definition. If you want clicks in one frame to generate ouput in
another, one way to control the destination is in the target attribute of links, e.g.,

    <a href="/cgi-bin/sfx.py?whatever=1&x=2" target="output_customer">click for customer stuff</a>

could be part of a control frame and would call on sfx.py to generate content in another frame.
You could also control stuff with javascript and DOM.

BTW, I couldn't find a "Display" method or function in any of the *py or *.c on my hard disk
python trees, so I assume it's in a module you imported. If so, which? It helps to let people
know a little about the context of your problem ;-)

If you are just running interactively, and Display essentially just sends one page to the
local browser by writing a temp file and invoking the browser, then what should the browser
think? It fill be looking for the other pages in the same temp file area.

If you are running a script, and Display basically just writes stdout, I'm still surprised you just
get a blank page. What does the browser show if you view source?

What are you actually doing? ;-)

Regards,
Bengt Richter




More information about the Python-list mailing list