[Zope-dev] Re: [Zope-DB] Thread in ZODB

2004-04-11 Thread Andreas Jung
You can't associate thread or locks as *persistent* attributes. Use 
_v_someattribute
instead.

-aj

P.S.  and please no crosspostings

--On Samstag, 10. April 2004 10:33 Uhr +0200 Andre Meyer 
[EMAIL PROTECTED] wrote:

Hi Zopers

Here is a nice challenge, I hope:

I have a multi-threaded Python application that I want to link to Zope.
The idea is to provide a Web interface for viewing and editing the state
of multiple threads running in Python. On thread should be associated
with Zope and act as the door between the ZServer and the other threads.
Unfortunately, I do not manage to create a reference to a thread in the
Zope product's main class because the ZODB refuses to add it.
This is the error message when trying to instantiate the product:
Site Error
An error was encountered while publishing this resource.
Error Type: UnpickleableError
Error Value: Cannot pickle type 'thread.lock' objects
And this is the code where it goes wrong:

class Zpyse(SimpleFolder):
  meta_type = Zpyse
   manage_options = (
{'label':'Edit', 'action':'manage_main'},
{'label':'View', 'action':'index_html'}
)
   index_html = PageTemplateFile('zpt/index_html', globals())
   def manage_editZpyse(self, title, REQUEST=None):
Method to edit Zpyse instances.
self.title = title
if REQUEST is not None:
return self.index_html(self, REQUEST)
   def __init__(self, id, title):
# Sender/Receiver Test
print 'init Zpyse'
ams = spyse.getAMS()
*   self.za = ams.createThread('ZopeThread', 'ZopeThread', globals())
qa = ams.createThread('Receiver', 'ReceiverThread', globals())
sa = ams.createThread('Sender', 'SenderThread', globals())
* only this goes wrong, the other threads are created (without self.).



Is there anybody with a good idea about how to handle this?

thanks a lot in advance
Andre




___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Re: [Zope-DB] Thread in ZODB

2004-04-11 Thread Andre Meyer
Thanks, the hint of Sandor with adding the thread as an attribute to the 
module instead of the class worked well for me.

sorry for cross-posting

kind regards
Andre
Andreas Jung wrote:

You can't associate thread or locks as *persistent* attributes. Use 
_v_someattribute
instead.

-aj

P.S.  and please no crosspostings

--On Samstag, 10. April 2004 10:33 Uhr +0200 Andre Meyer 
[EMAIL PROTECTED] wrote:

Hi Zopers

Here is a nice challenge, I hope:

I have a multi-threaded Python application that I want to link to Zope.
The idea is to provide a Web interface for viewing and editing the state
of multiple threads running in Python. On thread should be associated
with Zope and act as the door between the ZServer and the other 
threads.
Unfortunately, I do not manage to create a reference to a thread in the
Zope product's main class because the ZODB refuses to add it.
This is the error message when trying to instantiate the product:

Site Error
An error was encountered while publishing this resource.
Error Type: UnpickleableError
Error Value: Cannot pickle type 'thread.lock' objects
And this is the code where it goes wrong:

class Zpyse(SimpleFolder):
  meta_type = Zpyse
   manage_options = (
{'label':'Edit', 'action':'manage_main'},
{'label':'View', 'action':'index_html'}
)
   index_html = PageTemplateFile('zpt/index_html', globals())
   def manage_editZpyse(self, title, REQUEST=None):
Method to edit Zpyse instances.
self.title = title
if REQUEST is not None:
return self.index_html(self, REQUEST)
   def __init__(self, id, title):
# Sender/Receiver Test
print 'init Zpyse'
ams = spyse.getAMS()
*   self.za = ams.createThread('ZopeThread', 'ZopeThread', 
globals())
qa = ams.createThread('Receiver', 'ReceiverThread', globals())
sa = ams.createThread('Sender', 'SenderThread', globals())

* only this goes wrong, the other threads are created (without self.).



Is there anybody with a good idea about how to handle this?

thanks a lot in advance
Andre









--
Dr. Andre P. Meyerhttp://home.hccnet.nl/a.meyer/
TNO FEL Command  Control and Simulation, http://www.fel.tno.nl/div2/
Delft Cooperation on Intelligent Systems, http://www.decis.nl/
___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )