diff options
Diffstat (limited to 'examples/example_03.py')
-rw-r--r-- | examples/example_03.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/examples/example_03.py b/examples/example_03.py new file mode 100644 index 0000000..b94c39e --- /dev/null +++ b/examples/example_03.py | |||
@@ -0,0 +1,54 @@ | |||
1 | #!/usr/bin/env python | ||
2 | # Copyright (C) 2010 Leonard Thomas | ||
3 | # | ||
4 | # This file is part of dodai. | ||
5 | # | ||
6 | # dodai is free software: you can redistribute it and/or modify | ||
7 | # it under the terms of the GNU General Public License as published by | ||
8 | # the Free Software Foundation, either version 3 of the License, or | ||
9 | # (at your option) any later version. | ||
10 | # | ||
11 | # Foobar is distributed in the hope that it will be useful, | ||
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | # GNU General Public License for more details. | ||
15 | # | ||
16 | # You should have received a copy of the GNU General Public License | ||
17 | # along with dodai. If not, see <http://www.gnu.org/licenses/>. | ||
18 | |||
19 | |||
20 | ############################################################################## | ||
21 | # The following is for setting up the correct python path. Ignore this | ||
22 | # section for your project | ||
23 | import sys | ||
24 | import os.path as p | ||
25 | path = p.dirname(p.dirname(p.abspath(__file__))) | ||
26 | sys.path.append(path) | ||
27 | ############################################################################## | ||
28 | |||
29 | """ | ||
30 | This example requires that you have sqlalchemy installed as well as the | ||
31 | psycopg2 package. | ||
32 | |||
33 | On ubuntu you can do: | ||
34 | apt-get install libpq-dev | ||
35 | easy_install psycopg2 | ||
36 | easy_install sqlalchemy | ||
37 | |||
38 | """ | ||
39 | |||
40 | from dodai import Configure | ||
41 | |||
42 | |||
43 | def main(config): | ||
44 | print config.db.engine | ||
45 | print config.db.session | ||
46 | print config.home_directory | ||
47 | |||
48 | if __name__ == "__main__": | ||
49 | |||
50 | config = Configure('test') | ||
51 | db = config.dbs().load('test_db') | ||
52 | config.set('db', db) | ||
53 | config.set('home_directory', config.home_directory) | ||
54 | main(config()) | ||