[Zope] Zope and Threads

Johan Carlsson johanc@easypublisher.com
Fri, 11 Jul 2003 17:40:46 +0200


Stefan H. Holek wrote:
> --On Freitag, 11. Juli 2003 15:05 +0200 Johan Carlsson 
> <johanc@easypublisher.com> wrote:
> 
>> Or would it be safe to import Zope from within Zope (for instance a Zope
>> Product)?
> 
> 
> It is safe. No module will be imported twice.
> 
> There may be issues if you use Refresh (and Zope < 2.6.1) with your 
> Product, but I haven't tried.
> 
> Stefan

Quite right. Thanks Stefan!

After a short failure and a second test
I got my Stupid-LoadZope product to work.

This is surely a easier way to load the app.

It also proves for me that writting from a seperate
thread shouldn't be any problems.


LoadZope.__init__.py:

import ThreadedAsync
def do_it(map):
     import Zope
     app=Zope.app()

     get_transaction().begin()
     app.title='Dude it works just fine.'
     get_transaction().commit()
     app._p_jar.close()
     del app

ThreadedAsync.register_loop_callback(do_it)

The ThreadedAsync is needed because Zope.app isn't available until Zope
has started (I'm not sure why but it just wasn't there).




-- 
Johan Carlsson          Tel: + 46 8 31 24 94
Colliberty              Mob: + 46 70 558 25 24
Torsgatan 72            Email: johanc@easypublisher.com
SE-113 37 STOCKHOLM