From: Doug B. <dou...@gm...> - 2009-01-30 12:34:46
|
On Thu, Jan 29, 2009 at 11:21 PM, Brian Matherly <br...@gr...>wrote: > I think I found a way to have shared code among plugins. Check out the > latest trunk. A new directory has been added: "plugins/lib". In this > directory, there is one file named "libholiday.py". libholiday aggregates > the holiday file parsing needs of the WebCal, Birthday Report and Graphical > calendar reports. > > I have also divided "src/plugins/Calendar.py" into two files > "src/plugins/drawreport/Calendar.py" and > "src/plugins/textreport/BirthdayReport.py". "src/plugins/WebCal.py" has been > moved to "src/plugins/webreport/WebCal.py". > > This implementation seems to work, but it is not set in stone. Still up for > debate: > > 1) The name of "src/plugins/lib". I called it "lib" because it seems like > it should store pluggable libraries of code that is shared by other plugins. > But we considered other names like "common". Anyone have a strong > preference? Because I don't. > > 2) The name of "libholiday.py". I added "lib" as a prefix to indicate that > it is a library and not an actual plugin. Is this distinction useful? Any > better ideas? > > We should now be able to start dividing the rest of the plugins and move > them into their respective locations. > > ~Brian > Brian, That looks very clean, and clever! I like the way that it appears as just another plugin, and shows whether it loaded or not. I guess there isn't any problem with name spaces, because each of these will live in their own libXXX and only brought in when imported? The only issue related to all of these changes is: http://www.gramps-project.org/bugs/view.php?id=2637 I was going to put the type/directory in that tree list in the Load Plugins dialog, but it appears that there is a dictionary that uses the filename (not path) to lookup bits about the file. I think that this currently means that two plugins can't have the same name, even though they are in different subdirectories. On a related note, when I split up DefaultGramplets into their own files, I'm wondering if I should name them *Gramplet.py? For example, should the DataEntry Gramplet be: DataEntry.py or DataEntryGramplet.py? -Doug |