The essential part of the above script is just g.registerHandler('save2', 
my_callback). The rest is just for making possible to deactivate handler 
and to make every commit with the next natural number. While developing 
your handler, it is useful to be able to deactivate it in case of an error. 
Also if you change script and run it again it will register another version 
of your handler. Quite often, in development, I use the same method to 
un-register old version and then register the new one.

def reactivate(tag, handler):
    k = '_activation_%s_handler'%tag
        # this is just to prevent collisions
        # you can use whatever string as a key
    old_handler = c.user_dict.pop(k, None)
    if old_handler:
        g.unregisterHandler(tag, old_handler)
    g.registerHandler(tag, handler)
    c.user_dict[k] = handler
reactivate('save2', my_callback)

HTH Vitalije.

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/630dd216-994f-4a7a-805a-e1b20ed2ae34%40googlegroups.com.

Reply via email to