pystew  committed 7088c86


  • Participants
  • Parent commits 0f112c5

Comments (0)

Files changed (2)

  - contains templates needed by the Citadel client.
  You shouldn't have to worry about, api.Protocol is the class where you would implement missing parts of the low level Citadel Protocol and should be the only module you need to import and adapt to your needs.
+ When you instenciate the Citadel class, you must pass it a config object (this is typically a module, but it doesn't have to).
+ The config obect may the following attributes:
+  . server_adr  : the Citadel server adr  (mandatory)
+  . server_prt  : the Citadel server port (mandatory)
+  . admin_login : admin login             (optionnal)
+  . admin_psw   : admin password          (optionnal)
+  . log         : log file                (optionnal)
+If admin login or password are not specified, you will be asked for them as needed.
+If log is not specified (or evaluate to False) nothing will be logged.
         wf = self.sock.makefile('wb', 0) = rf.readline
         self.write = wf.write
-        self.logfil = self.config.log
+        self.logfil = hasattr(self.config, 'log') and self.config.log
         c, a = self.get()
         self.log(a[0], 'w')
     def log(self, txt, mode='a'):
-        if 0: print txt
-        log = open(self.logfil, mode)
-        log.write('%s\n'%txt)
-        log.close
+        if hasattr(self, 'logfil'):
+            log = open(self.logfil, mode)
+            log.write('%s\n'%txt)
+            log.close
     def connect(self, adr, port):
         for af, socktype, proto, cn, sa in socket.getaddrinfo(
             adr , port , 0 , socket.SOCK_STREAM