Kexi/Plugins/Scripts/Archives

From KDE Community Wiki
< Kexi‎ | Plugins‎ | Scripts

This page documents archived content regarding scripts.

Documentation

(2011)

Q: Is there documentation of objects and operations available for scripting, e.g. using python or ruby?

User asked:

> Is there a list of calls that can be made to Kexi to do something
> from a Python script?  For example:  Let's say from a form menu in Kexi
> it calls a Python script, that script then calls one form and based on
> the input from that form either calls another form or does some table
> action.  Now, what calls to Kexi are available to do this?

Answer by j.staniek

List of objects and operations is not documented separately of the source code, which uses the Kross bindings helpers that expose operations to python. The author is Sebastian Sauer (mail at dipe.org)

I am sorry but for now one needs to get the source code and look closer. There's no excuse for no documentation, other plans for delivering much more extensive set of scriptable objects. This means we keep the right to completely remove the current object model, with possibility (in theory) of breaking backward compatibility (e.g. for security reasons).

There are two areas:

  • kexi window and operations on it; this is exposed in code kexi/plugins/scripting/kexiscripting
  • kexidb objects and operations on them, i.e. database-access-related features; this is exposed in code kexi/plugins/scripting/kexidb

To learn what objects are, look at, let's look at kexi/plugins/scripting/kexiscripting/kexiscriptadaptor.h, which is: "Adaptor class that provides Kexi specific functionality to the scripting world." as has been described in the file.

In line 45, there is setObjectName("Kexi"). This means the object to use in scripting is called "Kexi".

Then after the line 47, "public Q_SLOTS:" we have list of operations (slots, i.e. C++ methods) like windowWidget, viewWidget, actions, and so on. i.e. calling Kexi.windowWidget() is possible.

All is documented there in the code. To use objects in Python, one needs to use bindings to Qt, since objects typically inherit functionality from Qt rather being written from scratch. The last operation exposed in this file is 'viewIsDirty'.