coherence.upnp.core.service (module)¶
Services¶
This module contains several classes related to services:
ServiceServer
¶
A Service server.
scpdXML
¶
A twisted.web.resource.Resource represing 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. It takes care of initializing the device’s service. Emits events which will be received by
Device
.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
.Warning
This class is special regarding EventDispatcher, because some events are initialized outside this class by the class
StateVariable
.-
Changed in version 0.9.0:
Migrated from extern.louie 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
-
logCategory
= 'service_client'¶
-
detection_completed
¶
-
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, StateVariable to the service
@ivar name: the name of the new StateVariable @ivar implementation: either ‘optional’ or ‘required’ @ivar instance: the instance number of the service that variable
should be assigned to, usually ‘0’- @ivar evented: boolean, or the special keyword ‘never’ if the variable
- doesn’t show up in a LastChange event too
- @ivar data_type: ‘string’,’boolean’,’bin.base64’ or
- various number formats
- @ivar dependant_variable: the name of another StateVariable that
- depends on this one
- @ivar default_value: the value this StateVariable should have by
- default when created for another instance of in the service
@ivar allowed_values: a C{list} of values this StateVariable can have @ivar has_vendor_values: boolean if there are values outside
the allowed_values list too- @ivar allowed_value_range: a C{dict} of ‘minimum’,’maximum’
- and ‘step’ values
- @ivar moderated: boolean, True if this StateVariable should only be
- evented via a LastChange event
-
register_vendor_action
(name, implementation, arguments=None, needs_callback=True)[source]¶ enables a backend to add an own, vendor defined, Action to the service
@ivar name: the name of the new Action @ivar implementation: either ‘optional’ or ‘required’ @ivar arguments: a C{list} if argument C{tuples},
like (name,direction,relatedStateVariable)- @ivar needs_callback: this Action needs a method in the backend
- or service class
-
-
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
-