Apologies for shouting...it's working! :-)
Not sure what the difference was apart from another restart of Chandler.
Thanks very much for the head start.
Cheers, Andre
On Wed, 28 Nov 2007 14:52:39 -0500, "Andre Mueninghoff"
<[EMAIL PROTECTED]> said:
> Hi Jeffrey,
>
> I know you guys are polishing off the branching of Desktop 0.7.3, but if
> you have a minute, I have a couple of questions about the scripts below.
> Not urgent, but I'm eager to move forward.
>
> I believe I'm (now) installing my plugin without error.
>
> Q1. I made one change to the init.py script in response to a runtime
> syntax error that halted Chandler in (my line 42) "for item in". Is my
> fix correct?
>
> -------Your code-------
> class YourPluginMenuBlock(Block):
> # the method name has to be the blockName of the BlockEvent above
> # sandwiched with "on" and "Event"
> def onActionOnYourPluginEvent(self, event):
> for item in
> Block.findBlockByName("MainView").getSidebarSelectedCollection():
> item_title = item.displayName
> # Python's print can't print unicode, encode as utf-8
> print item_title.encode('utf-8')
>
> -------My code-------
> class AndrePluginMenuBlock(Block):
> # the method name has to be the blockName of the BlockEvent above
> # sandwiched with "on" and "Event"
> def onActionOnAndrePluginEvent(self, event):
> for item in
> Block.findBlockByName("MainView").getSidebarSelectedCollection():
> item_title = item.displayName
> # Python's print can't print unicode, encode as utf-8
> print item_title.encode('utf-8')
>
> Q2. Might my "fix" be the cause of why I don't see a new menu item in
> the File Menu or any other menu?
>
> Thanks much,
> Andre
>
> On Mon, 19 Nov 2007 14:12:02 -0800, "Jeffrey Harris"
> <[EMAIL PROTECTED]> said:
> > Hi Poojan,
> >
> > Sorry for the slow response.
> >
> > > I am trying to write a simple Python script which dumps out all items in
> > > my Home collection as a text file. (Just the item names as a simple flat
> > > list, 1 line per item.) This attempt is related to my wanting to be able
> > > to print out a simple list of my items (see
> > > http://lists.osafoundation.org/pipermail/chandler-users/2007-October/000822.html).
> > >
> > > It is my understanding that since Chandler Desktop is written in Python,
> > > it is possible to run simple scripts to perform repeated (or desirable)
> > > tasks.
> > >
> > > I've tried to harness the tools->scripting menu item to do
> > > this--recording a script of a .ics file dump.
> > > However, this seems to record mostly wxWidget calls (including mouse
> > > clicks & keyboard presses). Furthermore, dumping as an .ics file isn't
> > > exactly what I want. (I would have to post-process the result to get
> > > only the item names. I've done this manually before, but there must be
> > > a better way.)
> >
> > There are different possible meanings of the word script. The record
> > script functionality you tried is focused on allowing users to repeat
> > actions inside Chandler, as you discovered, that isn't going to help you
> > with your project. You want to write a Python script that works with
> > data in Chandler.
> >
> > > My first step in this endeavor is to figure out how to get hold of my
> > > Home collection's object. Is there a way to get the Python object of a
> > > collection by simply knowing its name--or, really, a list of items in
> > > the repository that belong to a specific collection?
> >
> > Here's how to write and install a plugin for Chandler that can access
> > your collections (I've written it so it looks at the selected
> > collection).
> >
> > To make this work, you should create a new directory, I'll call it
> > YourPlugin. Create a file called setup.py:
> >
> > ----------
> > YourPlugin/setup.py
> > ----------
> >
> > from setuptools import setup
> >
> > setup(
> > name = "YourPlugin",
> > version = "0.1",
> > packages = ["your_plugin"],
> > entry_points = {
> > "chandler.parcels": ["YourPlugin package = your_plugin"],
> > },
> > )
> >
> > #---------- End of setup.py
> >
> > Next, create a subdirectory called your_plugin, with a file called
> > __init__.py:
> >
> > ----------
> > YourPlugin/your_plugin/__init__.py
> > ----------
> >
> > from application import schema
> > from osaf.framework.blocks import BlockEvent, MenuItem
> > from osaf.framework.blocks.Block import Block
> >
> > from i18n import MessageFactory
> > # using _ for unicode that will be displayed to users enables localizers
> > to
> > # change the unicode
> > _ = MessageFactory("YourPlugin")
> >
> > def installParcel(parcel, oldVersion=None):
> >
> > # find the parent menu for your new menu item
> > parentMenu = schema.ns('osaf.views.main', parcel).FileMenu
> >
> > # the code that should handle events when your menu item is chosen
> > handler = YourPluginMenuBlock.update(parcel, None,
> > blockName='YourPluginMenuHandler')
> >
> > # the event that's sent when your menu item is chosen
> > addYourPluginEvent = BlockEvent.update(parcel, None,
> > blockName='ActionOnYourPlugin',
> > dispatchEnum='SendToBlockByReference',
> > destinationBlockReference=handler)
> >
> > # create the menu item
> > MenuItem.update(parcel, None, blockName='YourPluginMenu',
> > title=_(u"Some action"),
> > accel = _(u'Ctrl+Shift+Y'),
> > helpString=_(u"This does something"),
> > event=addYourPluginEvent,
> > parentBlock=parentMenu)
> >
> >
> > class YourPluginMenuBlock(Block):
> > # the method name has to be the blockName of the BlockEvent above
> > # sandwiched with "on" and "Event"
> > def onActionOnYourPluginEvent(self, event):
> > for item in
> > Block.findBlockByName("MainView").getSidebarSelectedCollection():
> > item_title = item.displayName
> > # Python's print can't print unicode, encode as utf-8
> > print item_title.encode('utf-8')
> >
> > #---------- End of __init__.py
> >
> > To install your plugin, you'll need to use the python that comes with
> > Chandler (I'll call it chandler_python) in the YourPlugin directory:
> >
> > chandler_python setup.py develop
> >
> > Then, restart Chandler. To uninstall your plugin, you can always do:
> >
> > chandler_python setup.py develop -u
> >
> > You should rename YourPlugin whatever you want, of course. The action
> > method I included is just a stub that iterates over the items in the
> > collection and prints their titles, for your purposes you could pop up a
> > dialog to choose a file and write whatever you want to it.
> >
> > Hope that helps, feel free to ask if you have more questions!
> >
> > Sincerely,
> > Jeffrey
> > _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> >
> > Open Source Applications Foundation "chandler-dev" mailing list
> > http://lists.osafoundation.org/mailman/listinfo/chandler-dev
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> Open Source Applications Foundation "chandler-dev" mailing list
> http://lists.osafoundation.org/mailman/listinfo/chandler-dev
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Open Source Applications Foundation "chandler-dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/chandler-dev