KParts.ScriptableExtension

KDE 4.5 PyKDE API Reference

- KDE's Python API

# ScriptableExtension Class Reference

`from PyKDE4.kparts import *`

Inherits: QObject
Namespace: KParts

## Detailed Description

An extension class that permits KParts to be scripted (such as when embedded inside a KHTMLPart) and to access the host's scriptable objects as well.

See ScriptValueTypes for how values are passed to/from various methods here.

Since:
  4.5

\nosubgrouping

## Enumerations
ScriptLanguage | { ECMAScript, EnumLimit }
## Methods
| __init__ (self, QObject parent)
| acquire (self, long objid)
QVariant | callAsConstructor (self, KParts.ScriptableExtension callerPrincipal, long objId, [QVariant] args)
QVariant | callAsFunction (self, KParts.ScriptableExtension callerPrincipal, long objId, [QVariant] args)
QVariant | callFunctionReference (self, KParts.ScriptableExtension callerPrincipal, long objId, QString f, [QVariant] args)
QVariant | enclosingObject (self)
bool | enumerateProperties (self, KParts.ScriptableExtension callerPrincipal, long objId, QStringList result)
QVariant | evaluateScript (self, KParts.ScriptableExtension callerPrincipal, long contextObjectId, QString code, KParts.ScriptableExtension.ScriptLanguage language=KParts.ScriptableExtension.ECMAScript)
QVariant | get (self, KParts.ScriptableExtension callerPrincipal, long objId, QString propName)
bool | hasProperty (self, KParts.ScriptableExtension callerPrincipal, long objId, QString propName)
KParts.ScriptableExtension | host (self)
bool | isScriptLanguageSupported (self, KParts.ScriptableExtension.ScriptLanguage lang)
bool | put (self, KParts.ScriptableExtension callerPrincipal, long objId, QString propName, QVariant value)
| release (self, long objid)
bool | removeProperty (self, KParts.ScriptableExtension callerPrincipal, long objId, QString propName)
QVariant | rootObject (self)
bool | setException (self, KParts.ScriptableExtension callerPrincipal, QString message)
| setHost (self, KParts.ScriptableExtension host)
## Static Methods
KParts.ScriptableExtension | adapterFromLiveConnect (QObject parentObj, KParts.LiveConnectExtension oldApi)
KParts.ScriptableExtension | childObject (QObject obj)
| registerDBusTypes ()

## Method Documentation

__init__ | ( | self, |
|  | QObject | parent
| ) |  |  |

Values are passed to and from scriptable methods or properties as QVariants. Valid values may be bools, strings, and numbers (doubles), as well as the following custom types:

- Null
- Undefined
- Exception
- Object
- FunctionRef

All of these other than Object and FunctionRef also provide DBus marshallers. These are registered when ScriptableExtension.registerDBusTypes() is called, which is in particular done by ScriptableExtension constructor.

acquire | ( | self, |
|  | long | objid
| ) |  |  |

increases reference count of object objId

QVariant callAsConstructor | ( | self, |
|  | KParts.ScriptableExtension | callerPrincipal,
|  | long | objId,
|  | [QVariant] | args
| ) |  |  |

Try to use the object objId associated with 'this' as a constructor (corresponding to ECMAScript's new foo(bar, baz, glarch) expression).

QVariant callAsFunction | ( | self, |
|  | KParts.ScriptableExtension | callerPrincipal,
|  | long | objId,
|  | [QVariant] | args
| ) |  |  |

Try to use the object objId associated with 'this' as a function.

QVariant callFunctionReference | ( | self, |
|  | KParts.ScriptableExtension | callerPrincipal,
|  | long | objId,
|  | QString | f,
|  | [QVariant] | args
| ) |  |  |

Try to use a function reference to field f of object @objId as a function

QVariant enclosingObject | ( |  | self ) |

Returns an object that represents the host()'s view of us. For example, if the host is an HTML part, it would return a DOM node of an &lt;object&gt; handled by this part. May be undefined or null

Implemented in terms of objectForKid

bool enumerateProperties | ( | self, |
|  | KParts.ScriptableExtension | callerPrincipal,
|  | long | objId,
|  | QStringList | result
| ) |  |  |

Tries to enumerate all fields of object objId associated with this to result. Returns true on success

QVariant evaluateScript | ( | self, |
|  | KParts.ScriptableExtension | callerPrincipal,
|  | long | contextObjectId,
|  | QString | code,
|  | KParts.ScriptableExtension.ScriptLanguage | language=KParts.ScriptableExtension.ECMAScript
| ) |  |  |

Tries to evaluate a script code with the given object as its context. The parameter language specifies the language to execute it as. Use isScriptLanguageSupported to check for support.

QVariant get | ( | self, |
|  | KParts.ScriptableExtension | callerPrincipal,
|  | long | objId,
|  | QString | propName
| ) |  |  |

Tries to get field propName from object objId associated with 'this'.

bool hasProperty | ( | self, |
|  | KParts.ScriptableExtension | callerPrincipal,
|  | long | objId,
|  | QString | propName
| ) |  |  |

Returns true if the object objId associated with 'this' has the property propName.

KParts.ScriptableExtension host | ( |  | self ) |

Returns any registered parent scripting context. May be 0 if setHost was not called (or not call yet).

bool isScriptLanguageSupported | ( | self, |
|  | KParts.ScriptableExtension.ScriptLanguage | lang
| ) |  |  |

returns true if this extension can execute scripts in the given language

bool put | ( | self, |
|  | KParts.ScriptableExtension | callerPrincipal,
|  | long | objId,
|  | QString | propName,
|  | QVariant | value
| ) |  |  |

Tries to set the field propName from object objId associated with 'this' to value. Returns true on success

release | ( | self, |
|  | long | objid
| ) |  |  |

decreases reference count of object objId

bool removeProperty | ( | self, |
|  | KParts.ScriptableExtension | callerPrincipal,
|  | long | objId,
|  | QString | propName
| ) |  |  |

Tries to remove the field d propName from object objId associated with 'this'. Returns true on success

QVariant rootObject | ( |  | self ) |

Return the root scriptable object of this KPart. For example for an HTML part, it would represent a Window object. May be undefined or null

bool setException | ( | self, |
|  | KParts.ScriptableExtension | callerPrincipal,
|  | QString | message
| ) |  |  |

Tries to raise an exception with given message in this extension's scripting context. Returns true on success

setHost | ( | self, |
|  | KParts.ScriptableExtension | host
| ) |  |  |

Reports the hosting ScriptableExtension to a child. It's the responsibility of a parent part to call this method on all of its kids' ScriptableExtensions as soon as possible.

## Static Method Documentation

KParts.ScriptableExtension adapterFromLiveConnect | ( | QObject | parentObj,
|  | KParts.LiveConnectExtension | oldApi
| ) |  |  |

This returns a bridge object that permits KParts implementing the older LiveConnectExtension to be used via the ScriptableExtension API. The bridge's parent will be the parentObj.

KParts.ScriptableExtension childObject | ( | QObject | obj
| ) |  |  |

Queries obj for a child object which inherits from this ScriptableExtension class. Convenience method.

registerDBusTypes | ( |  | ) |

Registers dbus encodings of Null, Undefined, and Exception. This is called by the ScriptableExtension constructor, so you likely will not need to do so yourself

## Enumeration Documentation

ScriptLanguage

Enumerator:

  ECMAScript |
  EnumLimit = 0xFFFF |