dbus/python decorators.py,1.7,1.8 service.py,1.17,1.18
Robert McQueen
robot101 at freedesktop.org
Sun Nov 13 18:53:32 PST 2005
Update of /cvs/dbus/dbus/python
In directory gabe:/tmp/cvs-serv28091/python
Modified Files:
decorators.py service.py
Log Message:
2005-11-14 Robert McQueen <robot101 at debian.org>
* python/decorators.py, python/service.py: Add a new argument to the
dbus.service.method decorator called sender_keyword, which if set,
specifies the name of an argument which will be provided the bus
name of the method caller.
* test/python/test-client.py, test/python/test-service.py: Add a
method and test to check the sender_keyword functionality.
Index: decorators.py
===================================================================
RCS file: /cvs/dbus/dbus/python/decorators.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- decorators.py 7 Nov 2005 15:31:30 -0000 1.7
+++ decorators.py 14 Nov 2005 02:53:29 -0000 1.8
@@ -2,7 +2,7 @@
import inspect
import dbus_bindings
-def method(dbus_interface, in_signature=None, out_signature=None, async_callbacks=None):
+def method(dbus_interface, in_signature=None, out_signature=None, async_callbacks=None, sender_keyword=None):
_util._validate_interface_or_name(dbus_interface)
def decorator(func):
@@ -17,6 +17,9 @@
args.remove(async_callbacks[0])
args.remove(async_callbacks[1])
+ if sender_keyword:
+ args.remove(sender_keyword)
+
if in_signature:
in_sig = tuple(dbus_bindings.Signature(in_signature))
@@ -30,6 +33,7 @@
func._dbus_interface = dbus_interface
func._dbus_in_signature = in_signature
func._dbus_out_signature = out_signature
+ func._dbus_sender_keyword = sender_keyword
func._dbus_args = args
return func
Index: service.py
===================================================================
RCS file: /cvs/dbus/dbus/python/service.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- service.py 7 Nov 2005 15:31:30 -0000 1.17
+++ service.py 14 Nov 2005 02:53:29 -0000 1.18
@@ -294,6 +294,10 @@
keywords[return_callback] = lambda *retval: _method_reply_return(connection, message, method_name, signature, *retval)
keywords[error_callback] = lambda exception: _method_reply_error(connection, message, exception)
+ # include the sender if desired
+ if parent_method._dbus_sender_keyword:
+ keywords[parent_method._dbus_sender_keyword] = message.get_sender()
+
# call method
retval = candidate_method(self, *args, **keywords)
More information about the dbus-commit
mailing list