Dynamically adding reports

Derek Atkins warlord at MIT.EDU
Thu Jun 11 10:20:17 EDT 2009

Quoting Phil Longstaff <plongstaff at rogers.com>:

> I played around last night with how reports are loaded in the system. 
>  I basically replaced:
> (use-module (gnucash report report-A))
> (use-module (gnucash report report-B))
> which appears in standard-reports.scm, with
> (define (get-report-list) (list
>    'report-A
>    'report-B
> ))
> (for-each (lambda (x) (resolve-module (append '(gnucash report) x))) 
> (get-report-list))
> which does nothing new, but does allow me to replace 
> (get-report-list) with a function which returns the names of all .scm 
> files.  This will then allow a user/developer to just drop a new 
> report file into the reports directory, restart gnucash, and it will 
> be picked up.  Or, (get-report-list) could read the list of report 
> file names from a standard-report-names.txt file, which would allow 
> the user/developer to drop a report file into the reports directory, 
> add the file name to the standard-report-names.txt, then restart.  My 
> preference is for the former (fewer steps), but a little more 
> difficult.
> The reports directory currently holds all of the report files (both 
> standard and business) as well as some support files.  I think what I 
> will do is create a 'standard-reports' subdirectory to the reports 
> directory, and put the standard reports (or symlinks) there.  
> get-report-list will then have a single directory from which to get 
> all of the file names.
> Comments?

How do you determine the runtime location of this directory?
So long as it can be determined at runtime (and not a compile-time
constant) I think this is a perfectly reasonable idea.

> Phil


       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available

More information about the gnucash-devel mailing list