server fix
[systematiki.git] / systematiki.py
blobf3aab957bd7c9c4c7df8fe882bf5b51260268ad7
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 database.retrieve_object("docroot")(gtk_ui_cb_2)
75 def gtk_ui_cb_2(database, obj):
76 # ObjectView(obj)
77 print "I got %r" % obj
80 def main(argv):
81 config = ClientConfig(argv) # Might run and quit a gobject.MainLoop
82 if config.ui == "gtk":
83 gtk_ui(config)
84 # TODO: Command-line interface, web interface, brain interface, ...
85 return 0
88 if __name__ == "__main__":
89 import sys
90 sys.exit(main(sys.argv))