Context window is a feature of SPCoder that serves as a link between SharePoint object model and IronPython engine. By adding a .net object (SharePoint object or any other .net object) to the Context, you add it to IronPython engine and thus allow IronPython to use it in the execution of the scripts.
For example, if you add some SharePoint list object to the Context you can write the following code, which writes the titles of all list items to the out window:

for i in list.Items:

which is equivalent to:

out.writeCol(list.Items, "Title")

Items can be added to context by dragging and dropping from Explorer’s treeview:


Or by calling main.AddToContext method and passing the object as an argument.

For example, this call will add the root web of the SharePoint site object to context:



After an object has been added to Context, SPCoder assigns the variable name to it. You can use that name in your scripts to access the object.
SPCoder has naming strategy so the names of common variables are short and easy to use. For example, if you add SPSite object to Context, it gets the name site. Next SPSite object gets the name site1, etc. SPWeb objects are named web, web1,…; SPList objects list, list1,… Of course it is possible to rename the object in the Context by right clicking it and choosing Rename context menu item.
If you want to delete an object from Context, you can do it from context menu, by choosing Delete item.

Using variable names in scripts makes scripts easier to move from one server to another, since it won’t be necessary to change the script if some paths are different… just add appropriate objects to Context on new server and eventually rename them so they fit the script before executing.

Other features:

Main window | Explorer | Code editor | Describer | Properties | Autorun | Context | Log | Output

Last edited Jan 3, 2014 at 5:17 PM by tomdam, version 4