Plugin Experiences

Robert Collins robertc at robertcollins.net
Thu Jun 5 04:48:04 BST 2008


On Thu, 2008-06-05 at 13:20 +1000, Martin Pool wrote:
> 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.

Huh, I didn't notice the subclassing. Jono - did you try with a regular
command? 
Martin - the implementation decorates, even though it uses a subclass.
And I agree about callbacks, we even discussed this for status, but
working >> ideal some of the time :)

> > 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.

Old code FTW. It's just a testament to the age of looms.

> > 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?

I don't think thats a good idea.

-Rob
-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20080605/ea5a40b4/attachment.pgp 


More information about the bazaar mailing list