Global Functions & Decorators

@handler

Registers a function as a top-level menu handler with a URL prefix.

@handler('/video/myplugin', 'My Plugin', thumb='icon-default.png')
def Main():
    oc = ObjectContainer()
    oc.add(DirectoryObject(key=Callback(SubMenu), title="Browse"))
    return oc

Parameter

Type

Description

prefix

str

The URL prefix for this handler (e.g. '/video/myplugin').

name

str

Display name shown to users.

thumb

str

Resource name for icon image.

art

str

Resource name for background art.

titleBar

str

Resource name for title bar image.

share

bool

Whether to share this handler across plugins.

allow_sync

bool

Whether to allow sync for this handler.

@route

Registers a function to handle a specific URL path pattern.

@route('/video/myplugin/item/{id}')
def GetItem(id):
    ...

Parameter

Type

Description

path

str

URL path pattern. Can contain {param} placeholders.

method

str or list

HTTP method(s) ('GET', 'POST', ['GET','POST']).

allow_sync

bool

Whether to allow sync for this route.

Callback

Generates a callback URL path for the given function with optional keyword arguments.

DirectoryObject(key=Callback(SubMenu, title="Action"), title="Go")

Parameter

Type

Description

func

function

The function to call back.

**kwargs

any

Arguments to pass to the function. Values are URL-encoded.

Returns str — a URL path string.

@indirect

Marks a function as returning indirect content (content that requires a secondary lookup).

@deferred

Marks a function as deferred (content resolved lazily on demand).

@expose

Marks a function as callable from other plug-ins or from the server itself.

@thread (decorator)

Decorator that makes a function execute in a new background thread when called.

@spawn

Immediately executes the decorated function in a new thread.

@lock (decorator)

Decorator that acquires the named lock(s) before executing the function, releasing them afterward.

@parallelize / @parallel / @task

Decorators for parallel task execution (see Thread).