Plugin Experiences
Martin Pool
mbp at canonical.com
Thu Jun 5 04:20:52 BST 2008
On Thu, Jun 5, 2008 at 9:14 AM, Jonathan Lange <jml at mumak.net> wrote:
> Hello all,
>
> I've recently extended the 'loom' plugin to show the current thread in
> the output of 'bzr status'.
>
> Working with bzrlib is generally a pleasure. This time, however, there
> were a couple of things that tripped me up:
>
>
> 1. Decorating commands is tricksy and undocumented.
>
> See cmd_status in
> http://bazaar.launchpad.net/~bzr-loom-devs/bzr-loom/trunk/annotate/head:/commands.py
> for how I did it.
In other words by subclassing the existing command. As I wrote
separately to pickscrape, I think this is not as good as getting the
existing registered command and wrapping it, because it won't handle
multiple wrappers. I agree it'd be good to document it and maybe
improve the API. Ultimately perhaps some of this like extensions to
'status' belong in specific callbacks rather than command wrappers.
> It would be nice if this were better documented. A better API would be nice too.
>
> 2. Should I use 'print'?
>
> You'll notice that the commands.py file universally uses 'print' to
> generate user output. In a private email I was told that this no
> longer the done thing, and that 'self.outf.write' is the way to do it.
>
> http://bazaar-vcs.org/WritingPlugins doesn't say anything about this.
I believe you should be using outf and they should be fixed. It
handles the correct encoding of output.
But maybe it'd be simpler for us to just assign such an object to
sys.stdout while running the command?
Anyhow if you could add this to that document it would be great. Also
I'll add it to our developer documentation index.
--
Martin <http://launchpad.net/~mbp/>
More information about the bazaar
mailing list