This module implements classes to simplify template processing.
Classes
classTemplate
Class to simplify applying of templates in a NCS service callback.
Template(service, path=None)
Initialize a Template object.
The 'service' argument is the 'service' variable received in decorated cb_create method in a service class. ('service' can in fact be any maagic.Node (except a Root node) instance with an underlying Transaction). It is also possible to provide a maapi.Transaction instance for the 'service' argument in which case 'path' must also be provided.
The optional argument 'vars' may be provided in form of a Variables instance.
Arguments:
name -- template name (str)
vars -- template variables (template.Variables)
flags -- template flags (int, optional)
classVariables
Class to simplify passing of variables when applying a template.
Variables(init=None)
Initialize a Variables object.
The optional argument 'init' can be any iterable yielding a 2-tuple in the form (name, value).
Members:
add(...)
Method:
add(self, name, value)
Add a value for the variable 'name'.
The value will be quoted before adding it to the internal list.
Quoting works like this: If value contains ' all occurrences of " will be replaced by ' and the final value will be quoted with ". Otherwise, the final value will be quoted with '.
Arguments:
name -- service variable name (str)
value -- variable value (str, int, boolean)
add_plain(...)
Method:
add_plain(self, name, value)
Add a value for the variable 'name'.
It's up to the caller to do proper quoting of value.
For arguments, see Variables.add()
append(...)
Method:
append(self, object, /)
Append object to the end of the list.
clear(...)
Method:
clear(self, /)
Remove all items from list.
copy(...)
Method:
copy(self, /)
Return a shallow copy of the list.
count(...)
Method:
count(self, value, /)
Return number of occurrences of value.
extend(...)
Method:
extend(self, iterable, /)
Extend list by appending elements from the iterable.