Data Provider
Introduction
This library is included for easily queriying data in the incoming xml-paylod of the rednerpdf-request. It expects the xml-structure described in the priint:cloud documentation.
The library is built to be as extensible as possible. Aside from the default class "DataProvider" another class for a "generic" entity-type is included, that inherits from the base-class. This can be extended per project-requirements by adding further classes with default parameters and custom methods.
Initialization
After importing the library, an instance of the dataprovider can be initialized by calling either of the class initializers
my_lib = comet.pyImport("[xml]/library/data_provider.py")
entity = my_lib.DataProvider("my_string_id", "my_node_type")
other_entity = my_lib.GenericEntity("my_other_string_id", "my_other_node_type")
... or the library-function 'initialize_entity()' to dynamically evaluate, which entity is required, based on the input.
This is used in most default placeholder-scripts, so that users can specify the entity-type in the placeholder-options while creating templates in InDesign. Example:
entity = my_lib.initialize_entity("generic", {"id":comet.gRecordStringID,"type":comet.gNodeType})
While initialization, the comet module is checked for information on previous instances of ths class. In case previous node_type and string_id match the current ones, any previously cached key values are reused in this object.
Attributes that are checked in Comet-Module
comet.lib_dataprovider_previous_string_id
comet.lib_dataprovider_previous_type
comet.lib_dataprovider_cache