Extension Interoperability

RoboFont Forums Help / General Extension Interoperability

This topic contains 2 replies, has 2 voices, and was last updated by  Jack Jennings 7 years, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #5470

    Jack Jennings
    Participant

    Here’s my question of the moment: is it possible for robofont extensions to be aware of each other? Essentially I’m wondering if an extension could provide an API for other extensions to consume. I’m not necessarily looking for code examples, just wondering if any of the following are possible…

    * Is it possible to generate a list of the installed extensions in a python script? I know that from within an installed extension I could probably traverse up the current path until I got the the extensions folder, and then search around for the installed extensions, but I assume that there’s a native way of doing this.

    * Is it possible to add an extension to the python path in order to allow other extensions to import its libraries?

    * Is it possible to have an extension write to a global variable that is then accessible to other extensions? (I’m assuming no, but trying to cover my bases)

    * Is it possible to register custom events? that could then be triggered from within another extension?

    The web developer in me thinks that it might be possible to run a web server out of an extension, and have that available send requests to, but I really think that’s probably the worst solution I could come up with.

    #5471

    frederik
    Keymaster

    I suppose everything is possible :)

    * use the the ExtensionBundle object to manage your extensions

    from mojo.extensions import  ExtensionBundle
    print ExtensionBundle.allExtentions()
    

    see: extension API

    * to share variables/packages the best thing todo is to add the a root path with your packages to the python sys.path.

    an example install.py in an extension

    import sys
    import os
    
    sys.path.append(os.path.dirname(__file__))
    

    this allows to import modules from an extension

    * the python way of sharing global variables

    * Registering custom events will be possible in the next version!
    never thought about it to allow third party app use the same notification center, but this could be indeed very handy…

    good luck

    #5472

    Jack Jennings
    Participant

    Haha, not the answer I was expecting. Next time I’ll come up with more outlandish things to do.

    Sorry about missing the mogo.extensions thing. I guess I need to sit down with the docs and read everything over again to make sure I don’t ask any more dumb questions.

    Getting the list of extensions should work well for what I’m working on now, but one of those other methods will be handy down the line. Really looking forward to custom events. :D

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.