Gramps db proxys

View: New views
7 Messages — Rating Filter:   Alert me  

Gramps db proxys

by Robert Chéramy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

In the file src/gen/proxy/proxybase.py (trunk), the description says :
class ProxyDbBase(DbBase):
    """
    A proxy to a Gramps database. This proxy will act like a Gramps
database,
    but all data marked private will be hidden from the user.
    """

But I could not find any filtering out of private data in ProxyDbBase. I
think this is done in private.py, in which PrivateProxyDb inherits from
ProxyDbBase. If I am right, I think the description should be changed to
something more generic :
    """
    Base Class for building a proxy to a Gramps database. This proxy
will act like a Gramps database,
    but no filtering is done in this proxy.
    """



To be sure I understood the concept well : let us imagine I want to
implement a proxy that filters out *all* notes. Is it right that I have
to create a new class that inherits from ProxyDbBase and appropriate
Methods like for get_note_from_handle :

def get_note_from_handle(self, handle):
        """
        Hides all Notes to the user : None is returned.
        """
        return None


Thank you for your help,

tibob

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Gramps-devel mailing list
Gramps-devel@...
https://lists.sourceforge.net/lists/listinfo/gramps-devel

Bug tracker...

by nwallingford :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'll be doing work on the bug tracker over the next hour or so, so it
might be unavailable for short periods of time.

Have a coffee instead...

Nick Wallingford
nick@...

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Gramps-devel mailing list
Gramps-devel@...
https://lists.sourceforge.net/lists/listinfo/gramps-devel

Re: Gramps db proxys

by Brian Matherly :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Robert,

> In the file src/gen/proxy/proxybase.py (trunk), the
> description says :
> class ProxyDbBase(DbBase):
>     """
>     A proxy to a Gramps database. This proxy will act like
> a Gramps
> database,
>     but all data marked private will be hidden from the
> user.
>     """
>
> But I could not find any filtering out of private data in
> ProxyDbBase. I
> think this is done in private.py, in which PrivateProxyDb
> inherits from
> ProxyDbBase. If I am right, I think the description should
> be changed to
> something more generic :
>     """
>     Base Class for building a proxy to a Gramps database.
> This proxy
> will act like a Gramps database,
>     but no filtering is done in this proxy.
>     """

Yes, that string (and others) are wrong. I have fixed them in the source repository.

> To be sure I understood the concept well : let us imagine I
> want to
> implement a proxy that filters out *all* notes. Is it right
> that I have
> to create a new class that inherits from ProxyDbBase and
> appropriate
> Methods like for get_note_from_handle :
>
> def get_note_from_handle(self, handle):
>         """
>         Hides all Notes to the user : None is returned.
>         """
>         return None

Yes, you understand the concept well.

However, that solution isn't very extensible. To accomplish the same goal, I would suggest editing the filter proxy (filter.py) to accept note filters (in addition to person and event filters). To accomplish the task of filtering *all* notes, just pass in a filter that excludes all notes. However, this solution could be extended with more sophisticated filters - like filtering out all notes that contain a particular name.

~Brian

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Gramps-devel mailing list
Gramps-devel@...
https://lists.sourceforge.net/lists/listinfo/gramps-devel

Re: Gramps db proxys

by Robert Chéramy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Brian Matherly schrieb:
> However, that solution isn't very extensible. To accomplish the same goal, I would suggest editing the filter proxy (filter.py) to accept note filters (in addition to person and event filters). To accomplish the task of filtering *all* notes, just pass in a filter that excludes all notes. However, this solution could be extended with more sophisticated filters - like filtering out all notes that contain a particular name.
>  
Wow, modifying the filter proxy to accept note filters is much more work
than I expected. There are notes references everywhere and all
references have to be filtered out otherwise you get a lot of empty
notes at the import. I'm still working on it, I hope to submit a patch
someday...


I encountered on problem while playing : if I do a person filter which
is "NOT(every people in the database)", it will be ignored when
exporting an xml file : the whole database will be exported instead of a
database without persons.


And I have a last question regarding
FilterProxyDb.get_person_from_gramps_id : shouldn't the function return
something like self.get_person_from_handle(person.get_handle) instead of
simply "return person" ? I think the events are not filtered out this way.


Cheers,

tibob



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Gramps-devel mailing list
Gramps-devel@...
https://lists.sourceforge.net/lists/listinfo/gramps-devel

Re: Gramps db proxys

by Brian Matherly :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Robert,

> Wow, modifying the filter proxy to accept note filters is
> much more work
> than I expected. There are notes references everywhere and
> all
> references have to be filtered out otherwise you get a lot
> of empty
> notes at the import. I'm still working on it, I hope to
> submit a patch
> someday...
>
>
> I encountered on problem while playing : if I do a person
> filter which
> is "NOT(every people in the database)", it will
> be ignored when
> exporting an xml file : the whole database will be exported
> instead of a
> database without persons.

You should file an issue on the issue tracker (bugs.gramps-project.org).

> And I have a last question regarding
> FilterProxyDb.get_person_from_gramps_id : shouldn't the
> function return
> something like
> self.get_person_from_handle(person.get_handle) instead of
> simply "return person" ? I think the events are
> not filtered out this way.

Your understanding is correct. It looks like the entire function could be boiled down to:

        person = self.db.get_person_from_gramps_id(val)
        return self.get_person_from_handle(person.get_handle)

~Brian

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Gramps-devel mailing list
Gramps-devel@...
https://lists.sourceforge.net/lists/listinfo/gramps-devel

Re: Gramps db proxys

by Robert Chéramy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Robert Chéramy schrieb:
> Wow, modifying the filter proxy to accept note filters is much more work
> than I expected. There are notes references everywhere and all
> references have to be filtered out otherwise you get a lot of empty
> notes at the import. I'm still working on it, I hope to submit a patch
> someday...
>  
So I am almost done ! The attached patch against latest trunk adds a
Note Filter capability to xml, gedcom and xml-package exports.
To achieve this, I extended the existing filter proxy as Brian proposed.

I may have forgotten to filter notes on some objects and this is my
first python hacking anyway, so feel free to criticize my code, I'll be
happy to tune it so it can hopefully get into svn.

Cheers,

tibob


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Gramps-devel mailing list
Gramps-devel@...
https://lists.sourceforge.net/lists/listinfo/gramps-devel

proxy_filter_notes.dif (24K) Download Attachment

Re: Gramps db proxys

by Brian Matherly :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bob,

> > Wow, modifying the filter proxy to accept note filters
> is much more work
> > than I expected. There are notes references everywhere
> and all
> > references have to be filtered out otherwise you get a
> lot of empty
> > notes at the import. I'm still working on it, I
> hope to submit a patch
> > someday...
> >  
> So I am almost done ! The attached patch against latest
> trunk adds a
> Note Filter capability to xml, gedcom and xml-package
> exports.
> To achieve this, I extended the existing filter proxy as
> Brian proposed.
>
> I may have forgotten to filter notes on some objects and
> this is my
> first python hacking anyway, so feel free to criticize my
> code, I'll be
> happy to tune it so it can hopefully get into svn.

>From my initial peek at the patch, it looks like you are on the right track. If no one beats me to it, I'll try to have a closer look at it next week and either give you some feedback, or commit it. We'll get it into SVN one way or another.

Thanks so much for this. It will make a nice addition to Gramps.

~Brian

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Gramps-devel mailing list
Gramps-devel@...
https://lists.sourceforge.net/lists/listinfo/gramps-devel
LightInTheBox - Buy quality products at wholesale price