On Thu, 2003-12-11 at 01:50, Christian Tismer wrote:
[Stackless Zope App]
The key to this surprizing solution is tasklets, channels, and thread pickling.
Let me know your thoughts...
This is very impressive. Can we get the rest of the source code? like, what is the definition of "channel_send()"?
Well, this is all still a little ugly, and I didn't want to spoil the nice effect by such details. Actually, there are restrictions on what I can use from Stackless, since I'm writing in Restricted python. Without further additions to Stackless (which I din't understand, yet), Zope doesn't allow me to call methods on tasklets and channels, so I had to put things into external methods, which do these calls for me.
channel_send(ch, data) is just a wrapper and actually does ch.send(data)
same here: stackless_tasklet(prog) is a wrapper that calls stackless.tasklet(prog) since I cannot import my module.
Furthermore, these channels are not the builtin Stackless channels, but a fake Python class, which implements channels in Python. The reason was that Stackless channels don't have pickling support, yet. Also a reason why I call this a "preview". Anyway, it works and is not cheating. You might be interested in the "driver" code, which is a Python script as well (the "other side" that reads form the channel):
runDemo script: """ # Example code:
# Import a standard function, and get the HTML request and response objects. from Products.PythonScripts.standard import html_quote request = container.REQUEST RESPONSE = request.RESPONSE
# see whether we have a channel stored in the session
chname ='demo_channel' session = request.SESSION if not session.has_key(chname): ch = container.stackless_channel() t = container.stackless_tasklet(container.program) t(ch) # bind parameter del t session[chname] = ch ch = session[chname] data = container.channel_receive(ch) last = 0 if data is None: del session[chname] last = 1 return container.index_html(value=data, show_source=last) """
I will put some more work into this if I get more feedback, and add more infos to the website.
An interesting version would be to not use the session at all, but send the pickle together with the web page. That means to pickle by hand and to use encryption of course.
ciao - chris
-- Christian Tismer :^) <mailto:[EMAIL PROTECTED]> Mission Impossible 5oftware : Have a break! Take a ride on Python's Johannes-Niemeyer-Weg 9a : *Starship* http://starship.python.net/ 14109 Berlin : PGP key -> http://wwwkeys.pgp.net/ work +49 30 89 09 53 34 home +49 30 802 86 56 mobile +49 173 24 18 776 PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04 whom do you want to sponsor today? http://www.stackless.com/
Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce