GnuCash 2.4.99
python-bindings-doxygen.py
Go to the documentation of this file.
00001 ## @file 
00002 # @brief Documentation file for GnuCashs python bindings, input file for doxygen.
00003 #
00004 # This file holds the more explanatory parts of the doxygen-source-documentation.
00005 # You will find the contents at @ref python_bindings_page.
00006 #
00007 # @par To-Do:
00008 # @li Work out the relation of scheme/guile and python-bindings
00009 # @li maybe join python_bindings_page and group
00010 # @li work on the structure of the documentation to make it more clear
00011 # @li try to make SWIG include the documentation of the c-source
00012 # @li make function-links in SWIG-generated files work.
00013 # @li some words to the tests
00014 #
00015 # @author Christoph Holtermann
00016 # @date December 2010
00017 # @ingroup python_bindings
00018 
00019 
00020 ## @defgroup python_bindings
00021 #  Also have a look at the page @ref python_bindings_page.
00022 
00023 ## @defgroup python_bindings_examples
00024 #  @ingroup python_bindings
00025 #  The python-bindings come with quite a lot of example scripts.
00026 
00027 ##  @page python_bindings_page Python bindings
00028 #   Also have a look at group @ref python_bindings.
00029 #
00030 #   For the moment the python-bindings are only available via svn. They may be included
00031 #   in GnuCash 2.4.
00032 #
00033 #   They can be found in src/optional/python-bindings.
00034 #
00035 #   To enable them in the compilation process you have to add --enable-python-bindings
00036 #   to the call of ./configure.
00037 #
00038 #   As a starting point have a look at the \link python_bindings_examples example-scripts\endlink.
00039 #
00040 #   @section possibilities What are the Python bindings good for ?
00041 #
00042 #   The python bindings supply the ability to access a wide range of the core functions of GnuCash. You
00043 #   can read and write Transactions, Commodities, Lots, access the business stuff... You gain the ability
00044 #   to manipulate your financial data with a flexible scripting language.
00045 #
00046 #   Not everything GnuCash can is possible to access though. The bindings focus on basic accounting functions.
00047 #   Have a look at the examples to get an impression.
00048 #
00049 #   @section python_bindings_section Principles
00050 #   The python-bindings are generated using SWIG from parts of the source-files of GnuCash.
00051 #
00052 #   @note Python-scripts should not be executed while GnuCash runs. GnuCash is designed as
00053 #   a single user application with only one program accessing the data at one time. You can force your 
00054 #   access but that may corrupt data. Maybe one day that may change but for the moment there is no active development on that.
00055 #
00056 #   @subsection swigworks What SWIG does
00057 #
00058 #   SWIG extracts informations from the c-sources and provides access to the structures
00059 #   to python. It's work is controlled by interface files :
00060 # 
00061 #   @li gnucash_core.i
00062 #   @li timespec.i
00063 #   @li glib.i 
00064 #   @li @link base-typemaps.i src/base-typemaps.i @endlink This file is shared with Guile.
00065 #
00066 #   it outputs:
00067 #
00068 #   @li gnucash_core.c
00069 #   @li gnucash_core_c.py
00070 #
00071 #   If you have generated your own local doxygen documentation (by "make doc") after having compiled the python-bindings, doxygen
00072 #   will include SWIGs output-files. The official version at http://svn.gnucash.org/docs/HEAD/ does not include
00073 #   these files. It's actually quite interesting to have a look at them through doxygen, because they contain all that you can
00074 #   access from python.
00075 #
00076 #   This c-style-api is the bottom layer. It is a quite raw extract and close to the original source. Some more details are described further down.
00077 #
00078 #   For some parts there is a second layer of a nice pythonic interface. It is declared
00079 #   in 
00080 #   @li gnucash_core.py and 
00081 #   @li gnucash_business.py.
00082 #   @li function_class.py contains helper functions for that.
00083 #
00084 #   @section howto How to use the Python bindings
00085 #   @subsection highlevel High level python wrapper classes
00086 #   If you
00087 # 
00088 #   @code >> import gnucash @endcode
00089 #
00090 #   You can access the structures of the high level api. For Example you get a Session object by
00091 #
00092 #   @code >> session=gnucash.Session() @endcode
00093 #
00094 #   Here you will find easy to use things. But sometimes - and at the current level rather sooner than
00095 #   later - you may be forced to search for solutions at the :
00096 #
00097 #   @subsection c_style_api C-style-api
00098 #
00099 #   If you
00100 #
00101 #   @code >> import gnucash @endcode
00102 #
00103 #   The c-style-api can be accessed via gnucash.gnucash_core_c. You can have a look at all the possibilities
00104 #   at gnucash_core_c.py.
00105 #
00106 #   You will find a lot of pointers here which you can just ignore if input and output of the function have the
00107 #   same type.
00108 #
00109 #   For example you could start a session by gnucash.gnucash_core_c.qof_session_begin(). But if you just try
00110 #
00111 #   @code session=gnucash.gnucash_core_c.qof_session_begin() @endcode
00112 #
00113 #   you will get an error message and realize the lack of convenience for you have to add the correct function parameters.
00114 #
00115 #   Not all of the available structures will work. SWIG just takes everything from the sources that it is fed with and translates it. Not everything
00116 #   is a working translation, because not everything has been worked through. At this point you are getting closer to the developers who you can 
00117 #   contact at the mailing-list gnucash-devel@gnucash.org. There may be a workaround. Maybe the problem can only be fixed by changing SWIGs input 
00118 #   files to correctly translate the c-source. Feel free to post a question at the developers list. It may awaken the interest of someone who creates
00119 #   some more beautiful python-interfaces.
00120 #
00121 #   @section Thisorthat When to use which api ?
00122 #
00123 #   The start would surely be the high-level api for you can be quite sure to have something working and you will maybe find
00124 #   explanations in the example-scripts. If you search for something that is not yet implemented in that way you will have to
00125 #   take your way to the c-style-api.
00126 #
00127 #   @section pydoc (Further) documentation
00128 #
00129 #   @li The documentation you just read uses doxygen. It collects documentation in GnuCash's sources. Besides that there is
00130 #   @li the classic python-documentation using help() and docstrings. Have a look at both.
00131 #   @li There is a page in the GnuCash wiki at http://wiki.gnucash.org/wiki/Python
00132 #   @li You may also have a look into the archives of gnucash-devel@gnucash.org. 
00133 #   @li On Bugzilla there is also some interesting talk regarding the development process. 
00134 #   @li Then you can use the abilitys of svn to see the history of the code by @code svn log @endcode done in the directory of the python-bindings.
00135 #
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines