[referencer] Preliminary medline support (first python plugin)

Aurélien Naldi aurelien.naldi at gmail.com
Thu Jan 3 09:46:36 EST 2008


Le mercredi 02 janvier 2008 à 22:51 +0000, John Spray a écrit :
> On Wed, 2008-01-02 at 23:03 +0100, Aurélien Naldi wrote:
> > I have been playing with extending the plugin system to allow plugins to
> > add actions. It is nowhere near finished nor clean as I have been
> > learning C++ in the meanwhile, but here is a short patch, to avoid
> > duplicate work, start discussion and to force me to finish it later!
> 
> This looks like a reasonable place to start.  Suggestions:
>       * RUN should be something like DOCUMENT_ACTION.  There also needs
>         to be a way to express whether the action can be applied to just
>         one document or to multiple documents at the same time, perhaps
>         with another capability called DOCUMENT_MULTIACTION.  There is
>         probably a better way.

I renamed it (See the new version of the patch attached). I don't see a
better way for the multiple document stuff right now, so I'm just
letting it on the side. I also reworked the loading of python plugin to
avoid having mandatory stubs of the functions the plugin doesn't
implement (which allows to let the pubmed plugin unchanged and to skip
the "resolve" function in the lyx plugin.

>       * shortName is a one-word thing like "arxiv", while longName is a
>         description.  This means that for things in menus one needs
>         something else like actionName to be, for example, "Cite in
>         LyX", set in referencer_plugin_info.  However, that field would
>         be absent/meaningless in metadata plugins, which could get a bit
>         messy.

I used shortName as identifier for the action. I have now added fields
for the text and tooltip of the button. If the plugin doesn't have the
DOCUMENT_ACTION capability, these fields are not used (and can thus be
left undefined)

>       * There need to be hooks for updating sensitivity of the action,
>         not just on whether any documents selected, but also on (for
>         example) whether lyx is running.  It will be interesting to see
>         what  performance consequences there are associated with jumping
>         into a python plugin everytime updating status UI.

The other bib manager I used don't test if lyx is running. I guess that
detecting it when actually trying to use it and putting a warning is
enough for now. As I understand it the python interpreter is always
running and you have pointers to python functions preloaded, so the
performance cost should not be that bad if someone want to add this
later.

> 
> > Remaining work:
> > * actually call some python code in PythonPlugin.C
> > * give it the list of selected documents, so that it can do something.
> 
> How you give the Document to python is the interesting part.  I guess
> you could just do it as a dictionary of Document->getFields, (plus the
> document filename, key and type, which aren't included there).  It would
> be nicer to pass a full-fledged object to python, but I don't know how
> easy/hard this is.

I agree, defining a document as a python map seems enough for now, even
if a real python object would be much nicer to have. It looks like the
boost C++ libs have some tools to do this kind of stuff, but I'm too
unexperienced with both python and C++ to have a real look at it now.
I am a bit affraid that by doing so we may duplicate everything in
memory, which can be annoying if many documents are selected.

For now, I have just added a hook in the referencer python module to do
it. Mixing python and C++ is not as hard as I expected :). For now it
returns a string, but it should return the list of selected documents.

I can add another hook to return a list of the keys of selected
documents, which is all what I need for the lyx plugin. I also think
that the metadata resolvers could use a real acces to the document.

I may not have time to finish it before the end of the week, so here is
my current patch, feel free to improve it in the meantime.

Comments ?

Best regards.

-- 
Aurélien Naldi <aurelien.naldi at gmail.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: referencer_secondStep_pluginaction.diff
Type: text/x-patch
Size: 8385 bytes
Desc: not available
URL: <http://icculus.org/pipermail/referencer/attachments/20080103/2f5a5387/attachment.bin>


More information about the referencer mailing list