Introduction to Plugin Scripting

Plug-in Scripting is a scripting framework built into several out-of-the-box Verivo plug-ins that allows users to inject custom scripts at key stages in the data request and response process. It permits you to add business logic to a data source without having to develop or recompile code.

Our Plug-in Scripting tier utilizes IronPython, an altered version of the Python programming language that runs on top of Microsoft’s .NET Framework (http://en.wikipedia.org/wiki/IronPython). With Plug-in Scripting, custom scripting can manipulate the request and response objects, throw custom errors, and perform most functions that once took a custom plug-in to accomplish.

Each plug-in has a corresponding scripting file, located on the AppServer, that is referenced with each request. The file consists of Python scripts with functions, or ‘hooks’, that are called by the plug-in. Plug-in Scripting requires that the Verivo App Server is running ASP.NET 4.0.


Enabling Plug-in Scripting

 

  1. Create a file in the Verivo AppServer's “bin\plugins” directory named the same as your base plugin DLL, but with "py" as the file extension (for example,  RESTPlugin.py) - This file will automatically be called when your data source is accessed.

 

Sample Hooks

The following “hooks” are available within any Plug-in Scripting enabled plug-ins:


Pre-Processing:

HandleRequest (request)
{

#The request to the data source (e.g., containing GET and POST parameters for REST web services).

return request 
}

 

Login (RequestMessage) 
{

#A RequestMessage representing the login request, and a LoginResponseMessage if successful.

return LoginResponseMessage 
}

  

Post-Processing:

HandleRawResponse (response)
{

#The raw response from the data source (e.g., a string containing XML for REST web services).

return response 

}

HandleTableResponse (response)
{

#A DataTable representing the records (rows) and fields (columns) being returned to a view.

return response 

}

 

Sample Plug-in Scripting Script

The following Plug-in Scripting script will handle the raw response of a data source, manipulate it, and output it to the Verivo logs:

import clr
clr.AddReference("System.Xml")
from System.Text import StringBuilder

def HandleRawResponse(response):
       response = "Hello World"
       response = response.Replace("o", "0")
       #response will now read Hell0 W0rld
       plugin.PrintToLogger(20, response)

       return response

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk