| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Exporting is now done with the following two new functions:
1. `uzbl.export('external_name', function)`
2. `uzbl.export_dict({'name1': func1, 'name2': func2, ...})`
This system is preferable to the old `__export__` variable for several
reasons. The first being that the exporting system is now very similar
to the connect (read: `uzbl.connect(..)` and `uzbl.connect_dict({..})`)
system in the event manager.
And consider the following:
1. User wishes to write a plugin that doesn't connect to any events but
exports a function.
2. It's an arbitrary requirement that a plugin have an `init(uzbl)`
function.
3. The user would have done the following (example plugin snippet):
__export__ = 'my_function'
def my_function(uzbl, ..):
# Do something
def init(uzbl):
# Do nothing
pass
4. The user now does the following:
def my_function(uzbl, ..):
# do something
def init(uzbl):
uzbl.export('my_function', my_function)
Note that the name in `uzbl.export('external_name', function)` doesn't
need to match the function name. Example pseudo-python:
# In the plugin
>>> def hello(uzbl):
... return "Hello, World!"
>>> def init(uzbl):
... uzbl.export('say_hello', hello)
... print uzbl.say_hello()
# In the event manager
>>> plugin.init(uzbl)
Hello, World!
|