[Cubicweb] Scheduled hooks

Adrien Di Mascio adrien.dimascio at logilab.fr
Wed Oct 24 08:19:18 CEST 2012


Hi Stéphane,

On 23/10/2012 17:24, Stéphane Bugat wrote:
> I was wondering however if it was possible to create a kind of session hook for that, that will be executed not a session launch or session close but periodically?


You could create a ``server_startup`` hook that would register a 
"looping task", that is a function that will be executed periodically. 
Code will look like :

from cubicweb.server import hook

class SomeStartupHook(hook.Hook):
     __regid__ = 'my-hook'
     events = ('server_startup',)

     def __call__(self):
         self.repo.looping_task(24*60*60, my_func, arg1, arg2)


-- 
Adrien Di Mascio - LOGILAB, Paris (France).
Tél: 01.45.32.03.12
Formations - http://www.logilab.fr/formations
Développements - http://www.logilab.fr/services
Gestion de connaissances - http://www.cubicweb.org/



More information about the Cubicweb mailing list