[Zope] Py-Toc and zope products

Ed Colmar ed at greengraphics.net
Thu Jun 9 14:36:39 EDT 2005


Greetings.

I have been messing around with the py-TOC code, and am looking forward 
to implementing it into my zope/MySQL site.

I think I am missing something about how to connect it to my zope folder 
class

My goal with this is to tie in the AIM messages in with the folder class 
I am using in zope to affect database queries.  However, I've only been 
able to successfully get it running using the "bot" and "bm" classes as 
global variables (not self.bot and self.bm) so they are now outside the 
class where I need them... 

This was my best attempt at getting them inside the zope folder class, 
but zope does not like it...  Is there a better way?

class SystemofControlSite(Folder):
    def __init__(self, id, title, content):
        self.bot = MyBot("syscontrolbot23","pass")
        self.bot._info = "www.systemofcontrol.com notification bot."
        self.bm = BotManager()
        self.bm.addBot(self.bot,"myBot") # start it up
        time.sleep(1)

on init, I get this error:

*UnpickleableError*

Sorry, a site error occurred.

Traceback (innermost last):

    * Module ZPublisher.Publish, line 150, in publish_module
    * Module Products.PlacelessTranslationService.PatchStringIO, line
      51, in new_publish
    * Module ZPublisher.Publish, line 114, in publish
    * Module Zope, line 171, in zpublisher_exception_hook
    * Module ZPublisher.Publish, line 102, in publish
    * Module Zope, line 188, in commit
    * Module ZODB.Transaction, line 222, in commit
    * Module ZODB.Transaction, line 195, in commit
    * Module ZODB.Transaction, line 256, in _commit_objects
    * Module ZODB.Connection, line 387, in commit
      __traceback_info__:
      (('Products.SystemofControlSite.SystemofControlSite',
      'SystemofControlSite'), '\x00\x00\x00\x00\x00\x00\xdd1', '')

UnpickleableError: Cannot pickle <type 'file'> objects (Also, an error 
occurred while attempting to render the standard error message.)

I'm assuming this is because zope is attempting to make the bot 
connection persistant...


so then I did:

bot = MyBot("syscontrolbot23","pass")
bm = BotManager()
bm.addBot(bot,"myBot") # start it up


and use global variables to control it. 
    def initbot(self):
        """ create the bot  """
        global bot
        global bm
        bm.addBot(bot,"myBot") # start it up
        time.sleep(1)
        return 1

This sucks though becasue I cannot pass a message from AIM back into my 
zope product to do something with the database...

Any ideas?  Suggestions?

Cheers!

-ed


More information about the Zope mailing list