From: <bm...@ca...> - 2007-04-27 13:43:15
|
Doug, I think you underestimate the time needed to fill up the dictionary. With methods, only the database access is done the report needs. With a dictionary you have to get all possible data people might need on init. Benny Quoting "Douglas S. Blank" <db...@cs...>: > Don, > > I very much appreciate the work in trying to make report writing easier. > Some points: > > 1) Let's just make this part of the regular base report class; any easy > access changes should be available to experts and newbies alike. > > 2) Rather than creating a method for each easy data element, why not put > all of this in a dictionary? Then you could effectively have the same > output below with less code: > > person =3D self.getPersonData() > for key in person: > print key, person[key] > > 3) I like anything that hides the handles. Perhaps a dictionary could hav= e > some structure: > > data =3D self.getData() > print data["person"]["name"] > # or > for key in data["person"]: > print key, person[key] > > for child in data["children"]: > print child["name"] > > 4) Consider including the simplified GUI report options interface that I > added to plugins/Calendar.py. (It is currently broken for 2.3, I think). > Or, if there are issues, let me know and I can refine it. It really helps > in dealing with the creation and access of the options. > > [The method approach does allow parameters for each item. For example, I > know that I'd like to pass "%l, %f (%c)" to self.name...] > > -Doug > > On Fri, April 27, 2007 12:22 am, Don Allingham wrote: >> I've been working on trying to simplify report generation. Obviously, >> I'm attempting to make writing reports easier, so that more people would >> be willing to do this. >> >> The biggest issue is that accessing the database can be a bit confusing. >> So I've created a simpler interface for basic reports. Not everything is >> accessible in the simplified form, but what is should be much more >> understandable. >> >> Below is a sample of what a simple report would be that would print some >> basic information about a person. The variable "self.person" is the >> person that report is about. This is automatically set for you. >> >> class MyReport( SimpleReport ): >> >> def run( self ): >> print "Person : ", self.name( self.person ) >> print "Birth date : ", self.birth_date( self.person ) >> print "Birth place : ", self.birth_place( self.person ) >> print "Death date : ", self.death_date( self.person ) >> print "Death place : ", self.death_place( self.person ) >> print "Father : ", self.name( self.father(self.person ) ) >> print "Mother : ", self.name( self.mother(self.person ) ) >> print "Spouse : ", self.name( self.spouse(self.person ) ) >> print "Marriage Type : ", self.marriage_type( self.person ) >> print "Marriage Date : ", self.marriage_date( self.person ) >> print "Marriage Place: ", self.marriage_place( self.person ) >> >> for child in self.children( self.person ): >> print "Child : ", self.name( child ) >> >> The output of this report would look something like: >> >> Person : Garner, Lewis Anderson >> Birth date : 6/21/1855 >> Birth place : Great Falls, MT >> Death date : 6/28/1911 >> Death place : Twin Falls, ID >> Father : Garner, Robert W. >> Mother : Zieli=C5=84ski, Phoebe Emily >> Spouse : Martel, Luella Jacques >> Marriage Type : Married >> Marriage Date : 4/1/1875 >> Marriage Place: Paragould, AR >> Child : Garner, Eugene Stanley >> Child : Garner, Jesse V. >> Child : Garner, Raymond E. >> Child : Garner, Jennie S. >> Child : Garner, Walter E. >> Child : Garner, Daniel Webster >> Child : Garner, Bertha P. >> Child : Garner, Elizabeth >> >> So, to get the name of a person, you call: >> >> self.name( person ) >> >> To get the marriage date of the person (the primary marriage, if more >> than one) >> >> self.marriage_date( person ) >> >> So, hopefully, this will make things easier. >> >> Don >> >> ------------------------------------------------------------------------= - >> This SF.net email is sponsored by DB2 Express >> Download DB2 Express C - the FREE version of DB2 express and take >> control of your XML. No limits. Just data. Click to get it now. >> http://sourceforge.net/powerbar/db2/____________________________________= ___________ >> Gramps-devel mailing list >> Gra...@li... >> https://lists.sourceforge.net/lists/listinfo/gramps-devel >> > > > -- > Douglas S. Blank > Associate Professor, Bryn Mawr College > http://cs.brynmawr.edu/~dblank/ > Office: 610 526 6501 > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Gramps-devel mailing list > Gra...@li... > https://lists.sourceforge.net/lists/listinfo/gramps-devel > ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. |