From: Tim L. <guy...@gm...> - 2011-12-02 18:04:48
|
On 29 Nov 2011, at 06:53, Jérôme wrote: > Hi, > > I was a little bit stucked by the new source/citation handling! > For GeneWeb, I looked at libgedcom, but gedcom file format can fill > some data on citation fields, GeneWeb cannot. Otherwise, export to > GeneWeb ignore sources on person/family/events (3.2.x, 3.3.x), I > kept this limitation for the citation support/migration. Sources > import with this file format is full/complete! > > For this migration/support, Tim pointed out that method is modified: > we do not set an object any more when we add a source, but add > something like a relation with source.handle and commit it to the > database. > > Maybe to add a pseudo set_source() somewhere into gen.lib, will make > the code more 'direct'? Yes, it is indirectly related to > set_citation_list(), but only gedcom file format provides data on > citation (inherited by gedcom), ie. we need to generate an empty > citation for adding source during import on some file formats. > I guess this might be the same way on plugins (API, reports, tools, > gramplets, views, simple access, etc ...) > > 'gen.lib.citation.py' is equivalent to current 'gen.lib.src.py' > but maybe a quick access to something like this citation itself is > maybe missing? Could be an enhancement for gen.lib: a way to fill > citation_list with only one empty citation, then to fill/set > previous source fields? > > Note, to merge some 'empty' citations, makes my data 'more compact'! > ie. it is like cleaning all our empty sourceref (no data). > This is great for users but also for our databases. :) > > Minor changes which could be also merged is maybe the focus set for > some fields on Editors and minor improvements for accessibility (ATK > objects, tooltips, shortcuts, etc ...), but very cosmetic on the > 'merge into trunk' process. > > > Thanks! > Jérôme Jérôme, I think you are suggesting some convenience functions that would deal with the situation where a citation was empty. I had not included such functions, for several reasons: (1) There are probably not that many situations where there is no opportunity to have data in a citation. True, this might apply to GeneWeb, and it certainly applies to CSV, but I think that in most other cases there is at least the possibility to have information in the citation. (2) I tend to think that convenience functions that hide part of the functionality can make maintenance more complicated rather than simpler. You need to check what the convenience function is actually doing, and then check what the underlying code is doing. Of course, if that function is used a lot, then it may make things simpler, but if it is very little used, and only replaces a small amount of code, it may be more trouble than it is worth. (3) It is not obvious how the functions should work. If there are already citations attached to the object, how should these be treated? etc. Maybe one of them already points to the source, with or without data on the citation. I suggest that it is possible that one would want to control the processing in such cases. (4) The code is not very much changed from the existing code. The Citation primary object corresponds pretty closely to the SourceRef secondary object. You create the object, and set_reference_handle() to point to the Source object. There is a difference that you than have to do a db.add_citation(citation, transaction). You then do an obj.add_citation(citation_handle) instead of an obj.add_source_reference(sourcerefobj) to add the SourceRef/Citation to the object. (5) As far as data access is concerned, you do obj.get_citation_list() instead of obj.get_source_references() to get a list of Citation handles/SourceRefs respectively. With the citation, you then need to do a db.get_citation_from_handle(citation_handle). Having got the object, you do get_reference_handle() to get the source object handle. (By the way, note that the names of the functions and the return values are mostly chosen to match the way notes are attached to objects, so obj.add_citation(citation_handle) corresponds with add_note, and obj.get_citation_list() corresponds with get_note_list() - both returning handles). I am glad you appreciate the merits of merging the 'empty' citations. The possibility to merge citations is an important benefit of the change. |