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
- 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.
The following “hooks” are available within any Plug-in Scripting enabled plug-ins:
#The request to the data source (e.g., containing GET and POST parameters for REST web services).
#A RequestMessage representing the login request, and a LoginResponseMessage if successful.
#The raw response from the data source (e.g., a string containing XML for REST web services).
#A DataTable representing the records (rows) and fields (columns) being returned to a view.
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:
from System.Text import StringBuilder
response = "Hello World"
response = response.Replace("o", "0")
#response will now read Hell0 W0rld