[dev] [en] important core changes

Goffi goffi at goffi.org
Mar 24 Déc 15:55:28 CET 2013

G'day all,

I have made several important changes in core that I need to explain 
(N.B.: urwid_satext need to be updated too):

- a new Sessions class in memory.memory is used to managed time limited 
session. It act like a dict, and is automatically purge after a given 
timeout (default 10 min):

     * You first need to create the session with sessions = Sessions() 
(and optionaly the timeout or the profile, see below).

     * To create a session, just do session=newSession(). this return a 
session_id (a string) and a session_data object (an empty dict)

     * if session is accessed, the timeout is reset

     * if you have finished with the session, you can delete it with 
"del sessions[session_id]"

     * if your sessions need to be protected from other profiles access 
(needed for sensitive data, to avoid session_id guessing with 
multi-users frontends like Libervia), you can give a profile argument 
when creating the instance; in this case you have to use profileGet 
instead of the __getitem__ access.

- I have started a refactoring for importMenu and callbacks. The goal is 
to use a unique and easy callback system. The actionResult* methods are 
deprecated, and LaunchAction is now asynchronous. Callbacks can be used 
for many things: plugin menus, XMLUI buttons, form submitting, or 
anything than is launched by a frontend. Here's how they work:

     * You register a callback with core.sat_main.registerCallback. The 
first argument is the callback itself, then are arguments which will be 
sent back to the callback.

     * when registering a callback, you can use the following keyword 
arguments: "with_data" indicate that the callback need a dictionary data 
(e.g.: necessary for XMLUI form submitting). "force_id" indicate that 
you want to use you own id instead of the autogenerated one; this is 
generally a bad idea as this can lead to name conflicts.

     * registerCallback return you the callback id which be used in 
XMLUI or anywhere to reference the callback

- Import menu: don't use action id anymore and become asynchronous too. 
The refactoring is not finished yet, it will use callback system soon.

- Gateways plugin (XEP-0100) should be broken, I'll fix it soon.

- XMLUI now use submit_id which use the callback system (submit_id is a 
callback id). submit_id is mandatory if you create a form XMLUI (but if 
you know what you are doing, you can use empty string instead of None to 
bypass the restriction).

- XMLUI now manages session_id: if a session_id is specified, it means 
that a complex multi-panel UI is running, the frontends MUST return this id.

- in xml_tools: dataForm*2XML has been renamed to dataForm*2XMLUI 
because they now return a XMLUI instead of raw XML, so they can still be 
modified before sending.

- Urwid SàText now use a ListOption for GenericList and descendants: 
this is actually like a unicode (so it preserve compatibility), but it 
make the difference between "value" and "label": comparaisons are made 
against value, and values are returned in XMLUI results, but it's the 
label which is displayed. Again, it's necessary to update Urwit SàText 
to last dev version to use last dev version of SàT

- XMLUI refactoring is not finished: mainly frontends code still need to 
be factorised and cleaned

- Add-Hoc Commands are available. It's not fully finished, but it's 
working. You can add a command to answer with XEP_0050.addAdHocCommand. 
There are plenty of options but most of them are optional and everything 
is explained in docstring. I have added a command to change status as an 
example, this command is restricted to the same bare jid (tested with 
Gajim and Psi).


Plus d'informations sur la liste de diffusion dev