[Zope] Polling a folder
Charlie Reiman
creiman@kefta.com
Tue, 3 Sep 2002 10:18:58 -0700
Sounds like you're running into pesky persistence problems. In essence, your
objects don't live in memory, they live on disk. They get tossed and
reloaded more or less at random. As a result, things like threads, file
handles, and network or database connections require special tricks.
I see two options for you.
1) Xron or some similar separate scheduler product.
2) Module scoped objects
If you have an object with module scope, it will persist in memory for the
server lifetime. You should be able to make a thread object that lives
there. However, I've never tried to access Zope objects from a module
object, only vice versa. Given the strangeness that is acquisition, I
wouldn't be surprised if it didn't work.
OTOH, xron does manage to do something like this, so it clearly must be
possible.
> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
> GimsMail
> Sent: Tuesday, September 03, 2002 8:14 AM
> To: zope@zope.org
> Subject: [Zope] Polling a folder
>
>
> Hi all,
>
> What's the best way to Poll a folder in Zope (I want to check the folder
> every now and again for new items, perform some actions, etc.)
>
> I have tried creating a polling object that runs a loop in a
> thread and does
> the work I want it to do. I do this with a Zope Object inheriting from
> SimpleItem.SimpleItem. I invoke this object's run method in a thread with
> thread.start_new_thread(self.run,()). Zope doesn't seem too happy if I
> inherit from SimpleItem.SimpleItem and threading.Thread at the same time!
>
> The strange thing is I get acquisition problems that I'm battling
> to solve.
>
> Things like:
> self.aq_parent.Tables.id == 'Tables'
> self.aq_parent.Tables.QMessages.id == 'Tables' (??? Seems like
> QMessages is
> the same object as Tables)
> self.aq_parent.Tables.QMessages.sqlGet() == Attribute Error (it claims
> sqlGet does not exist, it does).
>
> Also, when using the ZMI to navigate to the offending folder (to
> see if the
> folders are there etc.) then the acquisition will suddenly start working
> again.
>
> I'm not sure if the fact that I'm polling in a thread has got
> anything to do
> with my problems, but I am sure that I'm sooooo confused!
>
> Etienne
>
> P.S. I'm currently battling Outlook to get it to send Plain Text mails, so
> please bear with me if this is in HTML!
>
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
>