|
From: Stephen C. <ste...@u4...> - 2008-04-22 23:56:59
|
Hi Jan,
Just send the file to stephen ( dot ) cattaneo ( at ) u4eatech ( dot ) com
Cheers,
Stephen
Jan Müller wrote:
> Stephen Cattaneo schrieb:
>
>> Hi Jan,
>>
>> I would gladly use it, as far review goes, I think I'm too new to
>> asterisk for that.
>>
>> Cheers,
>>
>> Stephen
>>
>> Jan Müller wrote:
>>
>>
>>> hi,
>>>
>>> triggered by the recent mailing list activities, i just began to scan
>>> the code of manager.py, and i found this:
>>>
>>> def event_dispatch(self):
>>> """This thread is responsible fore dispatching events"""
>>>
>>> # loop dispatching events
>>> while self._running.isSet():
>>> # get/wait for an event
>>> ev = self._event_queue.get()
>>>
>>> # if we got None as an event, we are finished
>>> if not ev:
>>> break
>>>
>>> # dispatch our events
>>>
>>> # first build a list of the functions to execute
>>> callbacks = self._event_callbacks.get(ev.name, [])
>>> callbacks.extend(self._event_callbacks.get('*', [])) # <- !!!
>>>
>>> # now execute the functions
>>> for callback in callbacks:
>>> if callback(ev, self):
>>> break
>>>
>>> what happens here is that the '*' callback handlers are explicitly added
>>> to the (mutable) list of ev.name handlers.
>>> i haven't tried it but this should lead to problems when unsubscribing a
>>> '*' handler since it still remains an
>>> ev.name handler. i suggest a list addition to prevent manipulation of
>>> the list of ev.name handlers:
>>>
>>> [...]
>>> # first build a list of the functions to execute
>>> callbacks = self._event_callbacks.get(ev.name, []) +
>>> self._event_callbacks.get('*', [])
>>> [...]
>>>
>>> when i find time (might take a while), i might try and implement some
>>> more of the API in the Manager class for myself.
>>>
>>> for instance, for an event/callback driven command 'Action: sippeers', i
>>> would implement a method that yields a set of the 'Event: PeerEntry'
>>> Events to spare a user the trouble of (un)subscribing a callback, making
>>> up ActionIds, etc.
>>>
>>> anyone besides me interested in this, both using and reviewing it?
>>>
>>> regards, Jan
>>>
>>> -------------------------------------------------------------------------
>>> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
>>> Don't miss this year's exciting event. There's still time to save $100.
>>> Use priority code J8TL2D2.
>>> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
>>> _______________________________________________
>>> Pyst-users mailing list
>>> Pys...@li...
>>> https://lists.sourceforge.net/lists/listinfo/pyst-users
>>>
>>>
>>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
>> Don't miss this year's exciting event. There's still time to save $100.
>> Use priority code J8TL2D2.
>> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
>> _______________________________________________
>> Pyst-users mailing list
>> Pys...@li...
>> https://lists.sourceforge.net/lists/listinfo/pyst-users
>>
>>
> hi stephen,
>
> there is a first alpha version ready. beware, it's not tested at all. if
> you wish to use or test it, please give me your mail address (or is it
> ok to paste a messy 1000-line code here?).
>
> to whom else it may concern:
>
> 1. i implemented a metamethod which takes the api help and generates
> methods for all simple (only response, no events) api actions from it:
>
> <code>[...,
> ('mailbox_status', 'MailboxStatus', """Action: MailboxStatus
> Synopsis: Check Mailbox
> Privilege: call,all
> Description: Checks a voicemail account for status.
> Variables: (Names marked with * are required)
> *mailbox: Full mailbox ID <mailbox>@<vm-context>
> actionid: Optional ActionID for message matching
> Returns number of messages.
> Message: Mailbox Status
> Mailbox: <mailboxid>
> Waiting: <count>
> """, ["mailbox", "actionid=None"]),
> ...]
> </code)
> yields
> <code>
> def mailbox_status(self, mailbox, actionid=None):
> [...]
> return self.send_action({'Action': 'MailboxStatus', 'mailbox':
> mailbox, 'actionid': actionid} # actionid only included if not None
> </code>
> so, extending it for other simple actions (e.g., "Zap..." which I did
> not implement because I have no zap module) boils down to adding some
> lines to a table. If the API doc stirngs were a little more
> standardized, one could even fully automatically parse the documentation.
>
> 2. í also implemented event callback handlers for 'SipPeers' and
> 'DBGet'. the corresponding methods yield a list(Event) (method
> sip_peers) and an Event (method db_get).
>
> regards j.
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> Pyst-users mailing list
> Pys...@li...
> https://lists.sourceforge.net/lists/listinfo/pyst-users
>
|