Re: [Zope3-Users] Periodically refresh RSS feeds
Am Dienstag, 19. Dezember 2006 13:03 schrieb Christian Theune: > Hi, > > Florian Lindner wrote: > > That's something I had mentioned in my posting too. It has advantage that > > the feeds could decide if they want to be called or not, whereas by > > the "utility-way" they would always be called. > > Considering your hesitation towards the component architecture, here's > some more input: I have no hesitations towards the component architecture. If I had I would not use Zope3. ;-) > Nowadays, registering a (persistent) object as a utility expresses > basically the same functionality. If it wants to be called, you can > register it as a utility for an interface (and maybe a name), if you > don't want to, you don't (or you unregister it). > > What you automatically get is: > > - you don't have to write your own registry code (again), > - the CA is optimized to do this kind of lookups Ok, these are two strong points. > > The distinction between software and content space was pretty much > removed now. Even content objects are software, or not? Ehh, got me... Ok, I'm convinced, I'll probably do it this way. Regards, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Periodically refresh RSS feeds
Hi, Florian Lindner wrote: > That's something I had mentioned in my posting too. It has advantage that the > feeds could decide if they want to be called or not, whereas by > the "utility-way" they would always be called. Considering your hesitation towards the component architecture, here's some more input: Nowadays, registering a (persistent) object as a utility expresses basically the same functionality. If it wants to be called, you can register it as a utility for an interface (and maybe a name), if you don't want to, you don't (or you unregister it). What you automatically get is: - you don't have to write your own registry code (again), - the CA is optimized to do this kind of lookups The distinction between software and content space was pretty much removed now. Even content objects are software, or not? Christian -- gocept gmbh & co. kg - forsterstraße 29 - 06112 halle/saale - germany www.gocept.com - [EMAIL PROTECTED] - phone +49 345 122 9889 7 - fax +49 345 122 9889 1 - zope and plone consulting and development signature.asc Description: OpenPGP digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Periodically refresh RSS feeds
Am Dienstag, 19. Dezember 2006 09:44 schrieb Thierry Florac: > Le mardi 19 décembre 2006 à 08:17 +0100, Christian Theune a écrit : > > Hi, > > > > Florian Lindner wrote: > > > Hello, > > > I have the following situation: > > > [...] > > Hi, > > I had a several problem to handle regular "alerts" which I solved in > this way : > - scheduling in done via the "schedule" package, available from Zope3 > SVN ; I created an "AlertManager" utility which is a subclass of > scheduler.CronTask (because my alerts are launched at fixed time, but > you can use other classes) That's what I already use. > - objects which can raise alerts are registered with a specific > interface IAlert > - when the AlertManager is launched, it opens a new connection (via > ZEO.ClientStorage), search for registered components (via > zapi.getAllUtilitiesRegisteredFor(IAlert)) and call one of the > interface's methods which may raise the alert. In my use case an email > is sent, but it could be any kind of alert that Python can handle. This is the same approach that Christian suggested. I have answered to his posting. Thanks, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Periodically refresh RSS feeds
Am Dienstag, 19. Dezember 2006 08:17 schrieb Christian Theune: > Hi, > > Florian Lindner wrote: > > Hello, > > I have the following situation: > > > > An object represents an RSS feed. It should be updated like every 20 > > minutes. If there is something new a Jabber message should be send out. > > > > Currently I have it implemented with an scheduler loop that emits an > > refreshRSSFeed event evey 20 minutes. My problem is that a handler for an > > event must be a static function, but I want a handler function to be > > called as a member of every instantiated RSS feed object. > > > > Another idea I have: > > Implement an utility where the RSS feeds could register a function that > > is called every 20 minutes. > > Another way would be that this utility takes an URL and monitors the URL > > for changes and only notifies the RSS Feed object in case of a change. > > > > How would you do that? > > So there's two problems here: scheduling and notifying persistent > objects about an event. No, only the notifying problem. > I don't have a good idea about the scheduling right now, except the hint > that using a 'zopectl run' script might be worthwhile. I'm not sure > what a 'scheduler function is'. I use the scheduler package from the Zope3 trunk and so far it works for me. > About notifying persistent objects: There is a method > 'getAllUtilitiesRegisteredFor(interface)' which might help you. Have a > look at zope/app/catalog/catalog.py beginning from line 150 > (indexDocSubscriber) how the catalog handles events and dispatches them > to multiple catalogs. I think this pretty much matches your use case if > you make each RSS feed a (named) utility. The RSS feed is a object that users could add and remove to arbitrary (sub-folders of there home-dir) folders. I would rather regard it as content object and I don't like adding utilities to content space (I have never really understood why content- and software-space have been mixed up). It would be possible, I think even technically superior to the next solution but somehome I don't like. > Of course you could also have a utility that maintains references to all > RSS feed objects and simply loops over them and calls a method for > refreshing. That's something I had mentioned in my posting too. It has advantage that the feeds could decide if they want to be called or not, whereas by the "utility-way" they would always be called. Thanks for your input, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Periodically refresh RSS feeds
Le mardi 19 décembre 2006 à 08:17 +0100, Christian Theune a écrit : > Hi, > > Florian Lindner wrote: > > Hello, > > I have the following situation: > > > > An object represents an RSS feed. It should be updated like every 20 > > minutes. > > If there is something new a Jabber message should be send out. > > > > Currently I have it implemented with an scheduler loop that emits an > > refreshRSSFeed event evey 20 minutes. My problem is that a handler for an > > event must be a static function, but I want a handler function to be called > > as a member of every instantiated RSS feed object. > > > > Another idea I have: > > Implement an utility where the RSS feeds could register a function that is > > called every 20 minutes. > > Another way would be that this utility takes an URL and monitors the URL > > for > > changes and only notifies the RSS Feed object in case of a change. > > > > How would you do that? > > So there's two problems here: scheduling and notifying persistent > objects about an event. > > I don't have a good idea about the scheduling right now, except the hint > that using a 'zopectl run' script might be worthwhile. I'm not sure > what a 'scheduler function is'. > > About notifying persistent objects: There is a method > 'getAllUtilitiesRegisteredFor(interface)' which might help you. Have a > look at zope/app/catalog/catalog.py beginning from line 150 > (indexDocSubscriber) how the catalog handles events and dispatches them > to multiple catalogs. I think this pretty much matches your use case if > you make each RSS feed a (named) utility. > > Of course you could also have a utility that maintains references to all > RSS feed objects and simply loops over them and calls a method for > refreshing. Hi, I had a several problem to handle regular "alerts" which I solved in this way : - scheduling in done via the "schedule" package, available from Zope3 SVN ; I created an "AlertManager" utility which is a subclass of scheduler.CronTask (because my alerts are launched at fixed time, but you can use other classes) - objects which can raise alerts are registered with a specific interface IAlert - when the AlertManager is launched, it opens a new connection (via ZEO.ClientStorage), search for registered components (via zapi.getAllUtilitiesRegisteredFor(IAlert)) and call one of the interface's methods which may raise the alert. In my use case an email is sent, but it could be any kind of alert that Python can handle. I'm far to know if this is the best approach, but at least it works quite efficiently... Thierry Florac -- Chef de projet intranet/internet Office National des Forêts - Département Informatique 2, Avenue de Saint-Mandé 75570 PARIS Cedex 12 Mél : [EMAIL PROTECTED] Tél. : +33 01.40.19.59.64 Fax. : +33 01.40.19.59.85 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Periodically refresh RSS feeds
Hi, Florian Lindner wrote: > Hello, > I have the following situation: > > An object represents an RSS feed. It should be updated like every 20 minutes. > If there is something new a Jabber message should be send out. > > Currently I have it implemented with an scheduler loop that emits an > refreshRSSFeed event evey 20 minutes. My problem is that a handler for an > event must be a static function, but I want a handler function to be called > as a member of every instantiated RSS feed object. > > Another idea I have: > Implement an utility where the RSS feeds could register a function that is > called every 20 minutes. > Another way would be that this utility takes an URL and monitors the URL for > changes and only notifies the RSS Feed object in case of a change. > > How would you do that? So there's two problems here: scheduling and notifying persistent objects about an event. I don't have a good idea about the scheduling right now, except the hint that using a 'zopectl run' script might be worthwhile. I'm not sure what a 'scheduler function is'. About notifying persistent objects: There is a method 'getAllUtilitiesRegisteredFor(interface)' which might help you. Have a look at zope/app/catalog/catalog.py beginning from line 150 (indexDocSubscriber) how the catalog handles events and dispatches them to multiple catalogs. I think this pretty much matches your use case if you make each RSS feed a (named) utility. Of course you could also have a utility that maintains references to all RSS feed objects and simply loops over them and calls a method for refreshing. Christian -- gocept gmbh & co. kg - forsterstraße 29 - 06112 halle/saale - germany www.gocept.com - [EMAIL PROTECTED] - phone +49 345 122 9889 7 - fax +49 345 122 9889 1 - zope and plone consulting and development signature.asc Description: OpenPGP digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Periodically refresh RSS feeds
Hello, I have the following situation: An object represents an RSS feed. It should be updated like every 20 minutes. If there is something new a Jabber message should be send out. Currently I have it implemented with an scheduler loop that emits an refreshRSSFeed event evey 20 minutes. My problem is that a handler for an event must be a static function, but I want a handler function to be called as a member of every instantiated RSS feed object. Another idea I have: Implement an utility where the RSS feeds could register a function that is called every 20 minutes. Another way would be that this utility takes an URL and monitors the URL for changes and only notifies the RSS Feed object in case of a change. How would you do that? Thanks, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users