Fixes
[systematiki.git] / systematiki.py
bloba936dc1aa5a0a3ca7fb307d7867b391f460c135f
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 """
4 Systematiki client.
6 The server is called 'systematikid.py'.
8 This client, once fully implemented, is intended to completely expose the
9 full potential of Systematiki. For actual day-to-day use, smaller clients
10 with a more limited set of features might be more suitable and friendly to
11 use.
12 """
14 # Copyright (C) 2007 Felix Rabe <public@felixrabe.textdriven.com>
16 # This library is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU Lesser General Public
18 # License as published by the Free Software Foundation; either
19 # version 2.1 of the License, or (at your option) any later version.
21 # This library is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 # Lesser General Public License for more details.
26 # You should have received a copy of the GNU Lesser General Public License
27 # along with this library; if not, write to the Free Software Foundation,
28 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
30 # Recommended line length or text width: 75 characters.
32 from PyGTKShell.RawConsole import *
34 from Systematiki.Database.Proxy import Database
35 from Systematiki.Networking.GObjectStringProtocol import StringProtocol
38 class ClientConfig(object):
39 """
40 Client configuration class.
42 TODO: Proper configuration using either command-line arguments,
43 configuration files, or a GUI.
44 """
46 def __init__(self, argv):
47 self.host = "localhost"
48 self.port = 6420
49 self.database_class = Database
50 self.ui = "gtk"
51 self.str_proto_class = StringProtocol
54 class ObjectView(Window):
56 def __init__(self, obj):
57 super(ObjectView, self).__init__()
58 self.set_title("Systematiki Object")
61 def gtk_ui(config):
62 database = config.database_class(config)
63 database.connect_client()(gtk_ui_cb_1)
64 main_loop_run()
67 def gtk_ui_cb_1(database):
68 if database is None:
69 print "no connection"
70 main_loop_quit()
71 return
72 print "calling retrieve_object..."
73 database.retrieve_object("docroot")(gtk_ui_cb_2)
76 def gtk_ui_cb_2(database, obj):
77 # ObjectView(obj)
78 print "I got %r" % obj
81 def main(argv):
82 config = ClientConfig(argv) # Might run and quit a gobject.MainLoop
83 if config.ui == "gtk":
84 gtk_ui(config)
85 # TODO: Command-line interface, web interface, brain interface, ...
86 return 0
89 if __name__ == "__main__":
90 import sys
91 sys.exit(main(sys.argv))