2013-12-17 08:42:53 +00:00
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" / >
< title > accounting.web — Accounting API 0.1-beta documentation< / title >
2013-12-20 15:00:09 +00:00
< link rel = "stylesheet" href = "../../_static/flasky.css" type = "text/css" / >
2013-12-17 08:42:53 +00:00
< link rel = "stylesheet" href = "../../_static/pygments.css" type = "text/css" / >
< script type = "text/javascript" >
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../',
VERSION: '0.1-beta',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
< / script >
< script type = "text/javascript" src = "../../_static/jquery.js" > < / script >
< script type = "text/javascript" src = "../../_static/underscore.js" > < / script >
< script type = "text/javascript" src = "../../_static/doctools.js" > < / script >
< link rel = "top" title = "Accounting API 0.1-beta documentation" href = "../../index.html" / >
2013-12-20 15:00:09 +00:00
< link rel = "up" title = "Module code" href = "../index.html" / >
< meta name = "viewport" content = "width=device-width, initial-scale=0.9, maximum-scale=0.9" >
2013-12-17 08:42:53 +00:00
< / head >
< body >
2013-12-20 15:00:09 +00:00
2013-12-17 08:42:53 +00:00
< div class = "related" >
< h3 > Navigation< / h3 >
< ul >
< li class = "right" style = "margin-right: 10px" >
< a href = "../../genindex.html" title = "General Index"
accesskey="I">index< / a > < / li >
2013-12-18 21:46:19 +00:00
< li class = "right" >
< a href = "../../http-routingtable.html" title = "HTTP Routing Table"
>routing table< / a > |< / li >
2013-12-17 08:42:53 +00:00
< li class = "right" >
< a href = "../../py-modindex.html" title = "Python Module Index"
>modules< / a > |< / li >
< li > < a href = "../../index.html" > Accounting API 0.1-beta documentation< / a > » < / li >
2013-12-20 15:00:09 +00:00
< li > < a href = "../index.html" accesskey = "U" > Module code< / a > » < / li >
2013-12-17 08:42:53 +00:00
< / ul >
< / div >
< div class = "document" >
< div class = "documentwrapper" >
< div class = "bodywrapper" >
< div class = "body" >
< h1 > Source code for accounting.web< / h1 > < div class = "highlight" > < pre >
2013-12-20 15:00:09 +00:00
< span class = "c" > # Part of accounting-api project:< / span >
< span class = "c" > # https://gitorious.org/conservancy/accounting-api< / span >
< span class = "c" > # License: AGPLv3-or-later< / span >
2013-12-17 08:42:53 +00:00
< span class = "sd" > ' ' ' < / span >
< span class = "sd" > This module contains the high-level webservice logic such as the Flask setup< / span >
< span class = "sd" > and the Flask endpoints.< / span >
< span class = "sd" > ' ' ' < / span >
< span class = "kn" > import< / span > < span class = "nn" > sys< / span >
< span class = "kn" > import< / span > < span class = "nn" > logging< / span >
< span class = "kn" > import< / span > < span class = "nn" > argparse< / span >
2013-12-20 15:00:09 +00:00
< span class = "kn" > from< / span > < span class = "nn" > flask< / span > < span class = "kn" > import< / span > < span class = "n" > Flask< / span > < span class = "p" > ,< / span > < span class = "n" > jsonify< / span > < span class = "p" > ,< / span > < span class = "n" > request< / span > < span class = "p" > ,< / span > < span class = "n" > render_template< / span >
< span class = "kn" > from< / span > < span class = "nn" > flask.ext.script< / span > < span class = "kn" > import< / span > < span class = "n" > Manager< / span >
< span class = "kn" > from< / span > < span class = "nn" > flask.ext.migrate< / span > < span class = "kn" > import< / span > < span class = "n" > Migrate< / span > < span class = "p" > ,< / span > < span class = "n" > MigrateCommand< / span >
2013-12-17 08:42:53 +00:00
2013-12-20 15:00:09 +00:00
< span class = "kn" > from< / span > < span class = "nn" > accounting.models< / span > < span class = "kn" > import< / span > < span class = "n" > Transaction< / span >
< span class = "kn" > from< / span > < span class = "nn" > accounting.storage< / span > < span class = "kn" > import< / span > < span class = "n" > Storage< / span >
< span class = "kn" > from< / span > < span class = "nn" > accounting.storage.ledgercli< / span > < span class = "kn" > import< / span > < span class = "n" > Ledger< / span >
< span class = "kn" > from< / span > < span class = "nn" > accounting.storage.sql< / span > < span class = "kn" > import< / span > < span class = "n" > SQLStorage< / span >
2013-12-17 08:42:53 +00:00
< span class = "kn" > from< / span > < span class = "nn" > accounting.transport< / span > < span class = "kn" > import< / span > < span class = "n" > AccountingEncoder< / span > < span class = "p" > ,< / span > < span class = "n" > AccountingDecoder< / span >
< span class = "kn" > from< / span > < span class = "nn" > accounting.exceptions< / span > < span class = "kn" > import< / span > < span class = "n" > AccountingException< / span >
2013-12-20 15:00:09 +00:00
< span class = "kn" > from< / span > < span class = "nn" > accounting.decorators< / span > < span class = "kn" > import< / span > < span class = "n" > jsonify_exceptions< / span > < span class = "p" > ,< / span > < span class = "n" > cors< / span >
2013-12-17 08:42:53 +00:00
< span class = "n" > app< / span > < span class = "o" > =< / span > < span class = "n" > Flask< / span > < span class = "p" > (< / span > < span class = "s" > ' accounting' < / span > < span class = "p" > )< / span >
< span class = "n" > app< / span > < span class = "o" > .< / span > < span class = "n" > config< / span > < span class = "o" > .< / span > < span class = "n" > from_pyfile< / span > < span class = "p" > (< / span > < span class = "s" > ' config.py' < / span > < span class = "p" > )< / span >
2013-12-20 15:00:09 +00:00
< span class = "n" > storage< / span > < span class = "o" > =< / span > < span class = "n" > Storage< / span > < span class = "p" > ()< / span >
< span class = "k" > if< / span > < span class = "nb" > isinstance< / span > < span class = "p" > (< / span > < span class = "n" > storage< / span > < span class = "p" > ,< / span > < span class = "n" > SQLStorage< / span > < span class = "p" > ):< / span >
< span class = "c" > # TODO: Move migration stuff into SQLStorage< / span >
< span class = "n" > db< / span > < span class = "o" > =< / span > < span class = "n" > storage< / span > < span class = "o" > .< / span > < span class = "n" > db< / span >
< span class = "n" > migrate< / span > < span class = "o" > =< / span > < span class = "n" > Migrate< / span > < span class = "p" > (< / span > < span class = "n" > app< / span > < span class = "p" > ,< / span > < span class = "n" > db< / span > < span class = "p" > )< / span >
< span class = "n" > manager< / span > < span class = "o" > =< / span > < span class = "n" > Manager< / span > < span class = "p" > (< / span > < span class = "n" > app< / span > < span class = "p" > )< / span >
< span class = "n" > manager< / span > < span class = "o" > .< / span > < span class = "n" > add_command< / span > < span class = "p" > (< / span > < span class = "s" > ' db' < / span > < span class = "p" > ,< / span > < span class = "n" > MigrateCommand< / span > < span class = "p" > )< / span >
2013-12-17 08:42:53 +00:00
< span class = "nd" > @app.before_request< / span >
< div class = "viewcode-block" id = "init_ledger" > < a class = "viewcode-back" href = "../../api/accounting.html#accounting.web.init_ledger" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > init_ledger< / span > < span class = "p" > ():< / span >
< span class = "sd" > ' ' ' < / span >
< span class = "sd" > :py:meth:`flask.Flask.before_request`-decorated method that initializes an< / span >
< span class = "sd" > :py:class:`accounting.Ledger` object.< / span >
< span class = "sd" > ' ' ' < / span >
< span class = "k" > global< / span > < span class = "n" > ledger< / span >
2013-12-20 15:00:09 +00:00
< span class = "c" > #ledger = Ledger(ledger_file=app.config[' LEDGER_FILE' ])< / span >
2013-12-17 08:42:53 +00:00
< span class = "c" > # These will convert output from our internal classes to JSON and back< / span > < / div >
< span class = "n" > app< / span > < span class = "o" > .< / span > < span class = "n" > json_encoder< / span > < span class = "o" > =< / span > < span class = "n" > AccountingEncoder< / span >
< span class = "n" > app< / span > < span class = "o" > .< / span > < span class = "n" > json_decoder< / span > < span class = "o" > =< / span > < span class = "n" > AccountingDecoder< / span >
< span class = "nd" > @app.route< / span > < span class = "p" > (< / span > < span class = "s" > ' /' < / span > < span class = "p" > )< / span >
< div class = "viewcode-block" id = "index" > < a class = "viewcode-back" href = "../../api/accounting.html#accounting.web.index" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > index< / span > < span class = "p" > ():< / span >
< span class = "sd" > ' ' ' Hello World! ' ' ' < / span >
< span class = "k" > return< / span > < span class = "s" > ' Hello World!' < / span >
2013-12-20 15:00:09 +00:00
< / div >
< span class = "nd" > @app.route< / span > < span class = "p" > (< / span > < span class = "s" > ' /client' < / span > < span class = "p" > )< / span >
< div class = "viewcode-block" id = "client" > < a class = "viewcode-back" href = "../../api/accounting.html#accounting.web.client" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > client< / span > < span class = "p" > ():< / span >
< span class = "k" > return< / span > < span class = "n" > render_template< / span > < span class = "p" > (< / span > < span class = "s" > ' client.html' < / span > < span class = "p" > )< / span >
2013-12-17 08:42:53 +00:00
< / div >
2013-12-20 15:00:09 +00:00
< span class = "nd" > @app.route< / span > < span class = "p" > (< / span > < span class = "s" > ' /transaction' < / span > < span class = "p" > ,< / span > < span class = "n" > methods< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "s" > ' OPTIONS' < / span > < span class = "p" > ])< / span >
< span class = "nd" > @cors< / span > < span class = "p" > ()< / span >
< span class = "nd" > @jsonify_exceptions< / span >
< div class = "viewcode-block" id = "transaction_options" > < a class = "viewcode-back" href = "../../api/accounting.html#accounting.web.transaction_options" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > transaction_options< / span > < span class = "p" > ():< / span >
< span class = "k" > return< / span > < span class = "n" > jsonify< / span > < span class = "p" > (< / span > < span class = "n" > status< / span > < span class = "o" > =< / span > < span class = "s" > ' OPTIONS' < / span > < span class = "p" > )< / span >
< / div >
< span class = "nd" > @app.route< / span > < span class = "p" > (< / span > < span class = "s" > ' /transaction/< string:transaction_id> ' < / span > < span class = "p" > ,< / span > < span class = "n" > methods< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "s" > ' OPTIONS' < / span > < span class = "p" > ])< / span >
< span class = "nd" > @cors< / span > < span class = "p" > ()< / span >
< span class = "nd" > @jsonify_exceptions< / span >
< div class = "viewcode-block" id = "transaction_by_id_options" > < a class = "viewcode-back" href = "../../api/accounting.html#accounting.web.transaction_by_id_options" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > transaction_by_id_options< / span > < span class = "p" > (< / span > < span class = "n" > transaction_id< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ):< / span >
< span class = "k" > return< / span > < span class = "n" > jsonify< / span > < span class = "p" > (< / span > < span class = "n" > status< / span > < span class = "o" > =< / span > < span class = "s" > ' OPTIONS' < / span > < span class = "p" > )< / span >
2013-12-17 08:42:53 +00:00
< / div >
< span class = "nd" > @app.route< / span > < span class = "p" > (< / span > < span class = "s" > ' /transaction' < / span > < span class = "p" > ,< / span > < span class = "n" > methods< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "s" > ' GET' < / span > < span class = "p" > ])< / span >
2013-12-20 15:00:09 +00:00
< span class = "nd" > @app.route< / span > < span class = "p" > (< / span > < span class = "s" > ' /transaction/< string:transaction_id> ' < / span > < span class = "p" > ,< / span > < span class = "n" > methods< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "s" > ' GET' < / span > < span class = "p" > ])< / span >
< span class = "nd" > @cors< / span > < span class = "p" > ()< / span >
< span class = "nd" > @jsonify_exceptions< / span >
< div class = "viewcode-block" id = "transaction_get" > < a class = "viewcode-back" href = "../../api/accounting.html#accounting.web.transaction_get" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > transaction_get< / span > < span class = "p" > (< / span > < span class = "n" > transaction_id< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ):< / span >
2013-12-17 08:42:53 +00:00
< span class = "sd" > ' ' ' < / span >
< span class = "sd" > Returns the JSON-serialized output of :meth:`accounting.Ledger.reg`< / span >
< span class = "sd" > ' ' ' < / span >
2013-12-20 15:00:09 +00:00
< span class = "k" > if< / span > < span class = "n" > transaction_id< / span > < span class = "ow" > is< / span > < span class = "bp" > None< / span > < span class = "p" > :< / span >
< span class = "k" > return< / span > < span class = "n" > jsonify< / span > < span class = "p" > (< / span > < span class = "n" > transactions< / span > < span class = "o" > =< / span > < span class = "n" > storage< / span > < span class = "o" > .< / span > < span class = "n" > get_transactions< / span > < span class = "p" > ())< / span >
< span class = "k" > return< / span > < span class = "n" > jsonify< / span > < span class = "p" > (< / span > < span class = "n" > transaction< / span > < span class = "o" > =< / span > < span class = "n" > storage< / span > < span class = "o" > .< / span > < span class = "n" > get_transaction< / span > < span class = "p" > (< / span > < span class = "n" > transaction_id< / span > < span class = "p" > ))< / span >
< / div >
< span class = "nd" > @app.route< / span > < span class = "p" > (< / span > < span class = "s" > ' /transaction/< string:transaction_id> ' < / span > < span class = "p" > ,< / span > < span class = "n" > methods< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "s" > ' POST' < / span > < span class = "p" > ])< / span >
< span class = "nd" > @cors< / span > < span class = "p" > ()< / span >
< span class = "nd" > @jsonify_exceptions< / span >
< div class = "viewcode-block" id = "transaction_update" > < a class = "viewcode-back" href = "../../api/accounting.html#accounting.web.transaction_update" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > transaction_update< / span > < span class = "p" > (< / span > < span class = "n" > transaction_id< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ):< / span >
< span class = "k" > if< / span > < span class = "n" > transaction_id< / span > < span class = "ow" > is< / span > < span class = "bp" > None< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "n" > AccountingException< / span > < span class = "p" > (< / span > < span class = "s" > ' The transaction ID cannot be None.' < / span > < span class = "p" > )< / span >
< span class = "n" > transaction< / span > < span class = "o" > =< / span > < span class = "n" > request< / span > < span class = "o" > .< / span > < span class = "n" > json< / span > < span class = "p" > [< / span > < span class = "s" > ' transaction' < / span > < span class = "p" > ]< / span >
< span class = "k" > if< / span > < span class = "n" > transaction< / span > < span class = "o" > .< / span > < span class = "n" > id< / span > < span class = "ow" > is< / span > < span class = "ow" > not< / span > < span class = "bp" > None< / span > < span class = "ow" > and< / span > < span class = "ow" > not< / span > < span class = "n" > transaction< / span > < span class = "o" > .< / span > < span class = "n" > id< / span > < span class = "o" > ==< / span > < span class = "n" > transaction_id< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "n" > AccountingException< / span > < span class = "p" > (< / span > < span class = "s" > ' The transaction data has an ID attribute' < / span >
< span class = "s" > ' and it is not the same ID as in the path' < / span > < span class = "p" > )< / span >
< span class = "k" > elif< / span > < span class = "n" > transaction< / span > < span class = "o" > .< / span > < span class = "n" > id< / span > < span class = "ow" > is< / span > < span class = "bp" > None< / span > < span class = "p" > :< / span >
< span class = "n" > transaction< / span > < span class = "o" > .< / span > < span class = "n" > id< / span > < span class = "o" > =< / span > < span class = "n" > transaction_id< / span >
< span class = "n" > storage< / span > < span class = "o" > .< / span > < span class = "n" > update_transaction< / span > < span class = "p" > (< / span > < span class = "n" > transaction< / span > < span class = "p" > )< / span >
< span class = "k" > return< / span > < span class = "n" > jsonify< / span > < span class = "p" > (< / span > < span class = "n" > status< / span > < span class = "o" > =< / span > < span class = "s" > ' OK' < / span > < span class = "p" > )< / span >
< / div >
< span class = "nd" > @app.route< / span > < span class = "p" > (< / span > < span class = "s" > ' /transaction/< string:transaction_id> ' < / span > < span class = "p" > ,< / span > < span class = "n" > methods< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "s" > ' DELETE' < / span > < span class = "p" > ])< / span >
< span class = "nd" > @cors< / span > < span class = "p" > ()< / span >
< span class = "nd" > @jsonify_exceptions< / span >
< div class = "viewcode-block" id = "transaction_delete" > < a class = "viewcode-back" href = "../../api/accounting.html#accounting.web.transaction_delete" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > transaction_delete< / span > < span class = "p" > (< / span > < span class = "n" > transaction_id< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ):< / span >
< span class = "k" > if< / span > < span class = "n" > transaction_id< / span > < span class = "ow" > is< / span > < span class = "bp" > None< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "n" > AccountingException< / span > < span class = "p" > (< / span > < span class = "s" > ' Transaction ID cannot be None' < / span > < span class = "p" > )< / span >
< span class = "n" > storage< / span > < span class = "o" > .< / span > < span class = "n" > delete_transaction< / span > < span class = "p" > (< / span > < span class = "n" > transaction_id< / span > < span class = "p" > )< / span >
< span class = "k" > return< / span > < span class = "n" > jsonify< / span > < span class = "p" > (< / span > < span class = "n" > status< / span > < span class = "o" > =< / span > < span class = "s" > ' OK' < / span > < span class = "p" > )< / span >
2013-12-17 08:42:53 +00:00
< / div >
< span class = "nd" > @app.route< / span > < span class = "p" > (< / span > < span class = "s" > ' /transaction' < / span > < span class = "p" > ,< / span > < span class = "n" > methods< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "s" > ' POST' < / span > < span class = "p" > ])< / span >
2013-12-20 15:00:09 +00:00
< span class = "nd" > @cors< / span > < span class = "p" > ()< / span >
2013-12-17 08:42:53 +00:00
< span class = "nd" > @jsonify_exceptions< / span >
< div class = "viewcode-block" id = "transaction_post" > < a class = "viewcode-back" href = "../../api/accounting.html#accounting.web.transaction_post" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > transaction_post< / span > < span class = "p" > ():< / span >
< span class = "sd" > ' ' ' < / span >
< span class = "sd" > REST/JSON endpoint for transactions.< / span >
< span class = "sd" > Current state:< / span >
< span class = "sd" > Takes a POST request with a ``transactions`` JSON payload and writes it to< / span >
< span class = "sd" > the ledger file.< / span >
< span class = "sd" > Requires the ``transactions`` payload to be __type__-annotated:< / span >
< span class = "sd" > .. code-block:: json< / span >
< span class = "sd" > {< / span >
< span class = "sd" > " transactions" : [< / span >
< span class = "sd" > {< / span >
< span class = "sd" > " __type__" : " Transaction" ,< / span >
< span class = "sd" > " date" : " 2013-01-01" ,< / span >
< span class = "sd" > " payee" : " Kindly T. Donor" ,< / span >
< span class = "sd" > " postings" : [< / span >
< span class = "sd" > {< / span >
< span class = "sd" > " __type__" : " Posting" ,< / span >
< span class = "sd" > " account" : " Income:Foo:Donation" ,< / span >
< span class = "sd" > " amount" : {< / span >
< span class = "sd" > " __type__" : " Amount" ,< / span >
< span class = "sd" > " amount" : " -100" ,< / span >
< span class = "sd" > " symbol" : " $" < / span >
< span class = "sd" > }< / span >
< span class = "sd" > },< / span >
< span class = "sd" > {< / span >
< span class = "sd" > " __type__" : " Posting" ,< / span >
< span class = "sd" > " account" : " Assets:Checking" ,< / span >
< span class = "sd" > " amount" : {< / span >
< span class = "sd" > " __type__" : " Amount" ,< / span >
< span class = "sd" > " amount" : " 100" ,< / span >
< span class = "sd" > " symbol" : " $" < / span >
< span class = "sd" > }< / span >
< span class = "sd" > }< / span >
< span class = "sd" > ]< / span >
< span class = "sd" > }< / span >
< span class = "sd" > }< / span >
< span class = "sd" > becomes::< / span >
< span class = "sd" > 2013-01-01 Kindly T. Donor< / span >
< span class = "sd" > Income:Foo:Donation $ -100< / span >
< span class = "sd" > Assets:Checking $ 100< / span >
< span class = "sd" > ' ' ' < / span >
2013-12-20 15:00:09 +00:00
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "nb" > isinstance< / span > < span class = "p" > (< / span > < span class = "n" > request< / span > < span class = "o" > .< / span > < span class = "n" > json< / span > < span class = "p" > ,< / span > < span class = "n" > Transaction< / span > < span class = "p" > ):< / span >
< span class = "n" > transactions< / span > < span class = "o" > =< / span > < span class = "n" > request< / span > < span class = "o" > .< / span > < span class = "n" > json< / span > < span class = "o" > .< / span > < span class = "n" > get< / span > < span class = "p" > (< / span > < span class = "s" > ' transactions' < / span > < span class = "p" > )< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > transactions< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "n" > request< / span > < span class = "o" > .< / span > < span class = "n" > json< / span > < span class = "p" > ]< / span >
2013-12-17 08:42:53 +00:00
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > transactions< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "n" > AccountingException< / span > < span class = "p" > (< / span > < span class = "s" > ' No transaction data provided' < / span > < span class = "p" > )< / span >
2013-12-20 15:00:09 +00:00
< span class = "n" > transaction_ids< / span > < span class = "o" > =< / span > < span class = "p" > []< / span >
2013-12-17 08:42:53 +00:00
2013-12-20 15:00:09 +00:00
< span class = "k" > for< / span > < span class = "n" > transaction< / span > < span class = "ow" > in< / span > < span class = "n" > transactions< / span > < span class = "p" > :< / span >
< span class = "n" > transaction_ids< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "n" > storage< / span > < span class = "o" > .< / span > < span class = "n" > add_transaction< / span > < span class = "p" > (< / span > < span class = "n" > transaction< / span > < span class = "p" > ))< / span >
2013-12-17 08:42:53 +00:00
2013-12-20 15:00:09 +00:00
< span class = "k" > return< / span > < span class = "n" > jsonify< / span > < span class = "p" > (< / span > < span class = "n" > status< / span > < span class = "o" > =< / span > < span class = "s" > ' OK' < / span > < span class = "p" > ,< / span > < span class = "n" > transaction_ids< / span > < span class = "o" > =< / span > < span class = "n" > transaction_ids< / span > < span class = "p" > )< / span >
2013-12-17 08:42:53 +00:00
< / div >
< div class = "viewcode-block" id = "main" > < a class = "viewcode-back" href = "../../api/accounting.html#accounting.web.main" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > main< / span > < span class = "p" > (< / span > < span class = "n" > argv< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ):< / span >
< span class = "n" > prog< / span > < span class = "o" > =< / span > < span class = "n" > __name__< / span >
< span class = "k" > if< / span > < span class = "n" > argv< / span > < span class = "ow" > is< / span > < span class = "bp" > None< / span > < span class = "p" > :< / span >
< span class = "n" > prog< / span > < span class = "o" > =< / span > < span class = "n" > sys< / span > < span class = "o" > .< / span > < span class = "n" > argv< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ]< / span >
< span class = "n" > argv< / span > < span class = "o" > =< / span > < span class = "n" > sys< / span > < span class = "o" > .< / span > < span class = "n" > argv< / span > < span class = "p" > [< / span > < span class = "mi" > 1< / span > < span class = "p" > :]< / span >
< span class = "n" > parser< / span > < span class = "o" > =< / span > < span class = "n" > argparse< / span > < span class = "o" > .< / span > < span class = "n" > ArgumentParser< / span > < span class = "p" > (< / span > < span class = "n" > prog< / span > < span class = "o" > =< / span > < span class = "n" > prog< / span > < span class = "p" > )< / span >
< span class = "n" > parser< / span > < span class = "o" > .< / span > < span class = "n" > add_argument< / span > < span class = "p" > (< / span > < span class = "s" > ' -v' < / span > < span class = "p" > ,< / span > < span class = "s" > ' --verbosity' < / span > < span class = "p" > ,< / span >
< span class = "n" > default< / span > < span class = "o" > =< / span > < span class = "s" > ' INFO' < / span > < span class = "p" > ,< / span >
< span class = "n" > help< / span > < span class = "o" > =< / span > < span class = "p" > (< / span > < span class = "s" > ' Filter logging output. Possible values:' < / span > < span class = "o" > +< / span >
2013-12-20 15:00:09 +00:00
< span class = "s" > ' CRITICAL, ERROR, WARNING, INFO, DEBUG' < / span > < span class = "p" > ))< / span >
< span class = "k" > global< / span > < span class = "n" > storage< / span >
< span class = "n" > storage< / span > < span class = "o" > =< / span > < span class = "n" > Ledger< / span > < span class = "p" > (< / span > < span class = "n" > app< / span > < span class = "o" > =< / span > < span class = "n" > app< / span > < span class = "p" > )< / span >
2013-12-17 08:42:53 +00:00
< span class = "n" > args< / span > < span class = "o" > =< / span > < span class = "n" > parser< / span > < span class = "o" > .< / span > < span class = "n" > parse_args< / span > < span class = "p" > (< / span > < span class = "n" > argv< / span > < span class = "p" > )< / span >
< span class = "n" > logging< / span > < span class = "o" > .< / span > < span class = "n" > basicConfig< / span > < span class = "p" > (< / span > < span class = "n" > level< / span > < span class = "o" > =< / span > < span class = "nb" > getattr< / span > < span class = "p" > (< / span > < span class = "n" > logging< / span > < span class = "p" > ,< / span > < span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > verbosity< / span > < span class = "p" > ,< / span > < span class = "s" > ' INFO' < / span > < span class = "p" > ))< / span >
< span class = "n" > app< / span > < span class = "o" > .< / span > < span class = "n" > run< / span > < span class = "p" > (< / span > < span class = "n" > host< / span > < span class = "o" > =< / span > < span class = "n" > app< / span > < span class = "o" > .< / span > < span class = "n" > config< / span > < span class = "p" > [< / span > < span class = "s" > ' HOST' < / span > < span class = "p" > ],< / span > < span class = "n" > port< / span > < span class = "o" > =< / span > < span class = "n" > app< / span > < span class = "o" > .< / span > < span class = "n" > config< / span > < span class = "p" > [< / span > < span class = "s" > ' PORT' < / span > < span class = "p" > ])< / span >
< / div >
< span class = "k" > if< / span > < span class = "n" > __name__< / span > < span class = "o" > ==< / span > < span class = "s" > ' __main__' < / span > < span class = "p" > :< / span >
< span class = "n" > main< / span > < span class = "p" > ()< / span >
< / pre > < / div >
< / div >
< / div >
< / div >
< div class = "sphinxsidebar" >
< div class = "sphinxsidebarwrapper" >
2013-12-20 15:00:09 +00:00
< p class = "logo" > < a href = "../../index.html" >
< img class = "logo" src = "../../_static/accounting-api-logo.png" alt = "Logo" / >
< / a > < / p > < h3 > Related Topics< / h3 >
< ul >
< li > < a href = "../../index.html" > Documentation overview< / a > < ul >
< li > < a href = "../index.html" > Module code< / a > < ul >
< / ul > < / li >
< / ul > < / li >
< / ul >
2013-12-17 08:42:53 +00:00
< div id = "searchbox" style = "display: none" >
< h3 > Quick search< / h3 >
< form class = "search" action = "../../search.html" method = "get" >
< input type = "text" name = "q" / >
< input type = "submit" value = "Go" / >
< input type = "hidden" name = "check_keywords" value = "yes" / >
< input type = "hidden" name = "area" value = "default" / >
< / form >
< p class = "searchtip" style = "font-size: 90%" >
Enter search terms or a module, class or function name.
< / p >
< / div >
< script type = "text/javascript" > $ ( '#searchbox' ) . show ( 0 ) ; < / script >
< / div >
< / div >
< div class = "clearer" > < / div >
< / div >
2013-12-20 15:00:09 +00:00
< div class = "footer" >
© Copyright 2013, Joar Wandborg.
Created using < a href = "http://sphinx.pocoo.org/" > Sphinx< / a > .
< / div >
2013-12-17 08:42:53 +00:00
< / body >
< / html >