My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
RuntimeEnvironment  
The underlying runtime environment
Updated Aug 24, 2011 by kevin.k1252@gmail.com

RuntimeEnvironment

Lignum consists of several modules. The runtime environment is one of them, it provides support for bundles that can be dynamically loaded at runtime.

Bundles

Bundles are dynamic modules. They are folders that contain at least two files:

  • __init__.py with start(args) and stop(args)
  • metainf.xml

The init.py function gets args as parameter, you will mostly only use the loader:

loader = args['loader']

For exposing http sites you make an entry into the routing table. But you can also use it for writing gui apps that run a gui main loop asynchronious and plugins can provide functionality for the main application by rpc.

This is an example plugin:

'''
This is just an example bundle.
'''

def start(args):
    
    loader = args['loader']

    router = loader.get_component('server.WSGI_Server').get_router()
    wrap = loader.get_component('utils.wrap')
    rpc = loader.get_component('rpc')

    @rpc.function
    def func():
        return 0

    def hello():
        return 'hello world'
    loader.register_component('hello', hello)
    
    @router.route('/base/main')
    def main(header, request, response_headers):
        return wrap('alert("main app")')
    
def stop(args):
    loader = args['loader']
    router = loader.get_component('server.WSGI_Server').get_router()
    router.delete_route('/base/main')

The metainf.xml contains the name, the version and dependencies:

<metainf>
    <dependencies>
        <bundle name="server"></bundle>
        <bundle name="utils"></bundle>
        <component name="server.WSGI_Server"></component>
    </dependencies>
    <version>1.0.0</version>
    <name>base</name>
    
</metainf>

Dependencies can be bundles or components, they all contain an attribute name. Bundles are the names of the bundles and components are the name of the component you would require.

Powered by Google Project Hosting