Module ncs.experimental
Experimental stuff.
This module contains experimental and totally unsupported things that may change or disappear at any time in the future. If used, it must be explicitly imported.
Classes
class DataCallbacks (log)
-
High-level API for implementing data callbacks.
Higher level abstraction for the DP API. Currently supports read operations only, as such it is suitable for config false; data.
Registered callbacks are searched for in registration order. Most specific points must be registered first.
args parameter to handler callbacks is a dictionary with keys matching list names in the keypath. If multiple lists with the same name exists the keys are named list-0, list-1 etc where 0 is the top-most list with name list. Values in the dictionary are python types (.as_pyval()), if the list has multiple keys it is set as a list else the single key value is set.
Example args for keypath /root/single-key-list{name}/conflict{first}/conflict{second}/multi{1 one}
Example handler and registration:
Class variables
var Pattern
-
Pattern matching key-path, internal to DataCallbacks
var RegisterPoint
-
Registered handler point, internal to DataCallbacks
Methods
def cb_exists_optional(self, tctx, kp)
-
low-level cb_exists_optional implementation
def cb_get_case(self, tctx, kp, choice)
-
low-level cb_get_case implementation
def cb_get_elem(self, tctx, kp)
-
low-level cb_elem implementation
def cb_get_next(self, tctx, kp, next)
-
low-level cb_get_next implementation
def cb_get_next_object(self, tctx, kp, next)
-
low-level cb_get_next_object implementation
def cb_get_object(self, tctx, kp)
-
low-level cb_get_object implementation
def cb_num_instances(self, tctx, kp)
-
low-level cb_num_instances implementation
def register(self, path, handler)
-
Register data handler for path.
If handler is a type it will be instantiated with the DataCallbacks log as the only parameter.
The following methods will be called on the handler:
-
get_object(kp, args)
Return single object as dictionary.
-
get_next(kp, args, next)
Return next object as dictionary, list of dictionaries can be returned to use result caching reducing the amount of calls required.
-
count(kp, args)
Return number of elements in list.
-
class Query (trans, expr, context_node, select, chunk_size=1000, initial_offset=1, result_as=3, sort=[])
-
Class encapsulating a MAAPI query operation.
Supports the pattern of executing a query and iterating over the result sets as they are requested. The class handles the calls to query_start, query_result and query_stop, which means that one can focus on describing the query and handle the result.
Example query:
Initialize a Query.
Methods
def next(self)
-
Get the next query result row.
def stop(self)
-
Stop the running query.
Any resources associated with the query will be released.