2012/5/31 Doug Blank <doug.blank@gmail.com>
On Thu, May 31, 2012 at 8:37 AM, Benny Malengier
<benny.malengier@gmail.com> wrote:
>
>
> 2012/5/25 Bastien Jacquet <bastien.jacquet_dev@m4x.org>
>>
>> I'm willing to help, but my OO python skill are quite limited.... (I am
>> used to object oriented c++ though)
>> So I cannot come up with the design, but once you have decided on this, I
>> will be happy to help. [Since I really want to be able to export as much
>> data to GeneaNet]
>>
>
> Did you manage?
> It seems Gedcomwriter usees __ for methods, so inheriting is officially
> diallowed.
> I never understood many of the designreasons to make so many things private
> instead of protected.
> You can circumvent that in python however, but writing becomes longer.

I also just ran into this problem with libgedcom. Perhaps at some
point we could apply a "fix" for these non-extendable classes:

s/__/_/

(That is as Benny suggests, make the methods protected rather than private.)

It seems that the only reason to make a method private is that it is
critical that a method is never overloaded, surely a rare case, yes?

Yes. Difficult call to make with business code. I would say ok for a getter/setter of properties, but otherwise, why avoid overloading?

Don  used a lot of private methods in his code, I don't know his reasoning. Perhaps just his coding style? Perhaps the idea was to make it protected if the need arises, but that limits the possibilities of 3th party plugins.

Benny
 

-Doug

> So, assuming you could inherit the methods without problems, your 3th party
> plugin would be as a quick hack:
>
> class MyGedcomWriter(GedcomWriter)
>   def __dump_event_stats(self, event, event_ref):
>        self.__myfamily_event_witness(event, 2)
>        super(MyGedcomWriter, self).__dump_event_stats(event, event_ref)
>
>  def  __myfamily_event_witness(self, event, level):
>       ' here your new code'
>
> A file with this, and correct import statements, and then a gpr.py file so
> the plugin will be loaded in Gramps.
>
> As inheritance does not work for __, you will need to call however
>      super(MyGedcomWriter, self)._GedcomWriter__dump_event_stats(event,
> event_ref)
> I think.
>
> Benny
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Gramps-devel mailing list
> Gramps-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gramps-devel
>