coherence.upnp.core.service (module)¶
Services¶
This module contains several classes related to services:
ServiceServer
¶
A Service’s server.
scpdXML
¶
A twisted.web.resource.Resource representing xml’s data for SCPD.
Note
SCPD is a Service Control Point Definition, for defining the actions offered by the various services in a UPnP’s network.
ServiceControl
¶
Object to control service’s SOAP actions.
-
class
Service
(service_type, service_id, location, control_url, event_sub_url, presentation_url, scpd_url, device)[source]¶ Bases:
eventdispatcher.eventdispatcher.EventDispatcher
,coherence.log.LogAble
This class represents a Device’s service. Emits events which will be received by class
Device
.-
Changed in version 0.9.0:
Migrated from louie/dispatcher to EventDispatcher
The emitted events changed:
Coherence.UPnP.Service.detection_completed => service_detection_completed
Coherence.UPnP.Service.detection_failed => service_detection_failed
Coherence.UPnP.DeviceClient.Service.Event.processed => service_event_processed
Coherence.UPnP.DeviceClient.Service.notified => service_notified
changed class variable
detection_completed
to benefit from the EventDispatcher’s properties
Note
This class initializes some events outside this class. This is done this way to make easier to make connections between this service and the module
dbus_service
, which uses some events triggered byStateVariable
. The mentioned events are (old => new):Coherence.UPnP.StateVariable.changed => state_variable_changed
Coherence.UPnP.StateVariable.{var name}.changed => state_variable_{var name}_changed
Warning
This class is special regarding EventDispatcher, because some events are initialized outside this class by the class
StateVariable
.-
logCategory
= 'service_client'¶
-
detection_completed
¶ To know whenever the service detection has completed. Defaults to False and it will be set automatically to True by the class method
parse_actions()
.
-
class
ServiceServer
(id, version, backend)[source]¶ Bases:
coherence.log.LogAble
-
logCategory
= 'service_server'¶
-
register_vendor_variable
(name, implementation='optional', instance=0, evented='no', data_type='string', dependant_variable=None, default_value=None, allowed_values=None, has_vendor_values=False, allowed_value_range=None, moderated=False)[source]¶ Enables a backend to add an own, vendor defined,
coherence.upnp.core.variable.StateVariable
to the service.- Parameters
name (str) – the name of the new StateVariable
implementation (str) – either ‘optional’ or ‘required’
instance – the instance number of the service that variable should be assigned to, usually ‘0’
evented (str) – boolean as string ‘yes’ ‘no’ or the special keyword ‘never’ if the variable doesn’t show up in a LastChange event too
data_type (str) – string, boolean, bin.base64 or various number formats
dependant_variable (object) – the name of another StateVariable that depends on this one
default_value (object) – the value this StateVariable should have by default when created for another instance of in the service
allowed_values (list) – a list of values this StateVariable can have
has_vendor_values (bool) – if there are values outside the allowed_values list too
allowed_value_range (dict) – a dict of ‘minimum’,’maximum’ and ‘step’ values
moderated (bool) – True if this StateVariable should only be emitted via a LastChange event
- Returns
A new variable of class
coherence.upnp.core.variable.StateVariable
-
register_vendor_action
(name, implementation, arguments=None, needs_callback=True)[source]¶ Enables a backend to add an own, vendor defined, Action to the service.
- Parameters
- Returns
An action of class
coherence.upnp.core.action.Action
-
-
class
scpdXML
(server, control=None)[source]¶ Bases:
twisted.web.static.Data
,coherence.log.LogAble
-
logCategory
= 'service_scpdxml'¶
-
render
(request)[source]¶ Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}
-
-
class
ServiceControl
[source]¶ Bases:
coherence.log.LogAble
-
get_action_results
(result, action, instance)[source]¶ check for out arguments if yes:
check if there are related ones to StateVariables with non A_ARG_TYPE_ prefix:
if yes:
check if there is a call plugin method for this action:
if yes: update StateVariable values with call result
if no: get StateVariable values and add them to result dict
- Parameters
result (object) – The result from an action
action (object) – An instance of class
coherence.upnp.core.action.Action
instance (object) – An instance of
coherence.upnp.core.variable.StateVariable
- Returns
An OrderedDict.
-