parent nodes: ChangeLog2004 | ChangeLog2006 | ChangeLog2009 | Menu Extra | OptionsDialog | WikiDocumentAttributes | WikidPadHelp
Inline Python Eval
Security concerns
WikidPad allows to evaluate and execute arbitrary Python scripts.
Because this is a potential security risk, script execution is
disabled by default.
To enable it, open the "Options" dialog, chapter "Other", item
"Script security". In the drop-down field you can enter the level
of security you want:
No scripts: Script execution is completely disabled. This is
the default.
No import_scripts: Scripts on the currently open page can be
executed and expressions evaluated. Importing scripts from
other pages with the import_scripts property doesn't work (see
below how to do this).
No global.import_scripts: Property "import_scripts" works,
but "global.import_scripts" does not
Allow everything
When pressing Ctrl-1 to Ctrl-6 WikidPad searches for a script normally in the following order:
Current page
Pages imported by current page with attribute "import_scripts"
Page imported somewhere with attribute "global.import_scripts"
The latter two are only searched if security settings allow it.
The order can be reversed by checking option "Reverse script search order (global imports first)" on options page "Security".
The following examples work therefore only with an appropriately relaxed security setting.
Evaluating expressions
You can evaluate Python expressions directly in the editor by
highlighting the expression and pressing CTRL-E. Example:
Highlight the calculation below, and type CTRL-E.
1+2+3
Executing scripts on the same page
You can also execute blocks of code within a document. Blocks of code
are defined within blocks. For example:
To execute the code above, type Ctrl-E. Ctrl-E actually will execute all
of the scripts on a page, including script imports.
You can assign up to 6 functions on a page to a Ctrl-# key. For example:
function 1:
function 2:
Type Ctrl-1 to execute function 1. Enter Ctrl-2 to execute function 2.
This will execute at most one script. If a script with this number is
found on the page, it is executed, if not, the local script imports
with import_scripts are searched. If no appropriate script is found
there either, the page mentioned in global.import_scripts is searched.
As already said, this happens only with the right security settings.
You can define your own functions for evaluation by copying
evalLibrary.py into a directory in the wikidPad install directory
called "user_extensions". This file will not be touched when upgrading
wikidPad.
file:///C|/Program%20Files/WikidPad/extensions/EvalLibrary.py
file:///C|/Program%20Files/WikidPad/user_extensions/EvalLibrary.py
Script Imports
You can import scripts from another page using the following attribute.
[import_scripts: GlobalScriptLibrary]
Type "Ctrl-4" to see the output from script 4 on the page
GlobalScriptLibrary.
You can also use [global.import_scripts: ...] property to define a single page which will be seen as if it was imported by every page of the wiki.
Editor Control Functions
See http://www.yellowbrain.com/stc/index.html for a list of the functions
available to the "editor" control.
Another Example
Highlight the line below and press CTRL-3
c:this pathwill be encoded.txt