[Zope] Feature requests and questions

Bill Randle billr@coinet.com
Tue, 13 Apr 1999 15:04:47 -0700


On Apr 13,  5:14pm, Michel Pelletier wrote:
} Subject: RE: [Zope] Feature requests and questions
}
} > From: andreww@netscape.com [mailto:andreww@netscape.com]
} > Sent: Tuesday, April 13, 1999 4:45 PM
} > To: Zope
} > Subject: [Zope] Feature requests and questions
} >
} > 2) Could Zope use javascript sometime in the future? the JS reference
} > implementation is open source as well, it could be incorporated...
}
} Hmm.. What do you mean by 'use javascript'?  You can put javascript in
} your DTML that will get sent to the browser, you can even use DTML to
} dynamicly generate javascript.  Do you mean use it internally to control
} the server or to be like DTML?

Here's something near and dear to my heart at the moment. I'm building a
web site using stock HTML, DTML, Zope, Python, and JavaScript (dynamically
generated via DTML). I would really love to reduce the number of languages
I'm dealing with by doing the JavaScript script stuff directly in Zope/Python.
I don't have the first clue as to how to do this, if it's even possible.

The main thing I use the JavaScript for is updating existing images on screen
by changing document.images[imagename].src after preloading a bunch of
images. The other is opening up a status or message window when the user
clicks on a button. These things can be done, of course, by using standard
form techniques and loading new pages, but I really like the ability to
quickly update an image on screen from another image stored in a JavaScript
Image object saved in cache.

I keep thinking there must be a better, more Zopeish, way to do this, but I
haven't stumbled across it yet.

Here's a far out thought: how about some way to access the browser DOM from
DTML or Python? I understand that the DOM and JavaScript live in the client,
rather than the host where Zope/Python is running. Perhaps there could be
some kind of DTML extension that would "auto-generate" JavaScript (some
equivalent) in the document? E.g. (ignore any syntax errors or issues):
	<!--#call "REQUEST.set('image1', zimage1)"-->
	<!--#call "REQUEST.set('image2', zimage2)"-->
	<!--#call "REQUEST.set('which_image', '1')"-->
	<img src=<!--#var path_to_zimage1--> name="myimage"
	    onCLick="<!--#call "imageswap"-->>render image 1
	</img>
Then lets say that "imageswap" is a DTML method that does something
like this:
	<!--#if "which_image == '1'"-->
	    <!--#var "myimage = image2"-->
	    <!--#call "REQUEST.set('which_image', '2')"-->
	<!--#else-->
	    <!--#var "myimage = image1"-->
	    <!--#call "REQUEST.set('which_image', '1')"-->
	<!--#/if>

This could generate a little JavaScript code to download with the page, if
necessary. E.g.:
	<script language="JavaScript">
	<!--  // hide me
	var which_image = 1;
	function imageswap()
	{
	    if (which_image == 1)
	    {
		document.images['myimage'].src = image2.src;
	        which_image = 2;
	    }
	    else
	    {
		document.images['myimage'].src = image1.src;
	        which_image = 1;
	    }
	}
	//-->
	</script>

Why would one want do this this, you ask? For one, if a person didn't know JS,
they could still use some of the JS capabilities without having to learn JS.

Anyway, just one wild idea for an integration/cooperation of Zope and JS.

	-Bill Randle
	Central Oregon Internet
	billr@coinet.com