[kforge-dev] programaticaly installing plugin

Rufus Pollock rufus.pollock at okfn.org
Tue Feb 26 22:05:28 UTC 2008


Martin Fuzzey wrote:
> Hi all,

Sorry for the delay in replying.

> I'm trying to install plugins from a script.
> 
> docs/plugin_system.txt says to do :
> 
> $ kforge-admin create plugin <plugin-name>

Sorry here, it seems that documentation is simply wrong -- it must have 
been written in anticipation of implemented code rather than to reflect 
it :)

> However this command is not recognized "Sorry, not a valid command: 
> create plugin svn"
> 
> Indeed I can't see anywhere in the code where this command is implemented
> 
> cli_shell.txt on the other hand gives another approach involving 
> directly manipulating the domain objects in python.
> 
> This works when run manually in interactive mode so I thought I could 
> use the "-c" option to kforge-admin to pass a script file, however the 
> -c option appears not to be implemented
> 
> Indeed from dm/cli/admin.py:
> 
>     def runScript(self):
>         # todo: Generalise implementation in provide.cli.admin
>         pass

Ok, that would be useful. Another todo item!

> So what's the correct way of installing plugins - I like the 
> "korge-admin create plugin" method since it keeps the knowledge of the 
> domain model within kforge itself.
> 
> Am I missing something here?

At present one does this by hand, i.e. by booting up a shell:

$ kforge-admin shell
 >>> import kforge
 >>> app = kforge.getA() # or kforge.soleInstance
 >>> app.registry.plugins.create('mypluginname')

> I _could_ make it work as is by doing a kforge-admin --interactive 
> combined with input redirection but that seems a bit of a hack to me.
> 
> So unless there are any objections I propose to patch 
> kforge/cli/admin.py to implement the "create plugin" command.
 >
> OTOH maybe "plugin create" would be more consistent with the otther 
> commands which are of noun/verb form "db init" "www build" etc

I think plugin create is probably more consistent with the way the cmd 
module works in python since all the code for plugins will then be 
inside the same method.

Thus all you need to do is add

def do_plugin(self, line=None):
     etc

~rufus




More information about the kforge-dev mailing list