RCS file: /cvsroot/WorldPilot/WorldPilot.py,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 WorldPilot.py --- WorldPilot.py 2000/01/28 05:35:52 1.1.1.1 +++ WorldPilot.py 2000/01/31 04:33:03 @@ -281,12 +281,13 @@ class Logon: usedUIDs={} - def __init__(self,User,Passwd,IP): + def __init__(self,User,Passwd,IP,imapserver): self.User=User self.Passwd=Passwd self.IP=IP self.Caches={} self.UID=self.genUID() + self.imapserver=imapserver try: self.Signature=open("/var/spool/worldpilot/user/%s/signature" % (User), "r").read() except: @@ -330,10 +331,9 @@ return Resource.Standard.callResource(ResourceName,'us', client=client, mapping=mapping) def checkPasswd(self): - HOST="localhost" try: - #self.Connection=imaplib.IMAP4(HOST) - Connection=imaplib.IMAP4(HOST) + #self.Connection=imaplib.IMAP4(self.imapserver) + Connection=imaplib.IMAP4(self.imapserver) #return self.Connection.login(self.User, self.Passwd) return Connection.login(self.User, self.Passwd) except: @@ -357,9 +357,8 @@ def getNewConnection(self): - HOST="localhost" try: - conn=imaplib.IMAP4(HOST) + conn=imaplib.IMAP4(self.imapserver) if conn.login(self.User, self.Passwd): return conn else: @@ -906,7 +905,7 @@ else: return None -DefaultLogon=Logon(None,None,None) +DefaultLogon=Logon(None,None,None,None) SESSIONROOT="/var/spool/worldpilot/sessions" @@ -986,17 +985,25 @@ if Sessions.initialized: return 1 Sessions.initialized=1 + if hasattr(parent, 'imapserver'): + imapserver = parent.imapserver + else: + imapserver = 'localhost' + if hasattr(parent, 'smtpserver'): + smtpserver = parent.smtpserver + else: + smtpserver = 'localhost' print "INITIALIZING SESSIONS" try: Sessions.logons=cPickle.Unpickler(open(SESSIONROOT+'/Logons','rb')).load() for logon in Sessions.logons.keys(): - self.createWorldPilotSession(parent, Sessions.logons[logon]) + self.createWorldPilotSession(parent, Sessions.logons[logon], imapserver, smtpserver) except: pass print "DIDNT WORK TO LOAD SESSIONS" - def createWorldPilotSession(self, parent, thisLogon, REQUEST=None): + def createWorldPilotSession(self, parent, thisLogon, imapserver, smtpserver, REQUEST=None): if thisLogon==None: previous=self.findPreviousSession(REQUEST) if previous: @@ -1008,7 +1015,7 @@ if thisLogon==None: if REQUEST.has_key('User') and REQUEST.has_key('Passwd'): print "!HAS USER" - thisLogon=Logon(REQUEST['User'], REQUEST['Passwd'], "172") + thisLogon=Logon(REQUEST['User'], REQUEST['Passwd'], "172", imapserver) print thisLogon if thisLogon.check(): self.registerLogon(thisLogon) @@ -1024,6 +1031,7 @@ thisLogon.getUID(), thisLogon.getUser(), thisLogon.getUser(), + smtpserver, ) NewWorldPilot.aq_parent=parent NewWorldPilot._WorldPilot=parent @@ -1213,11 +1221,12 @@ ('View',('','menu','prog','logonhtml'),('Anonymous','Manager')), ) - def __init__(self,id,title, Session): + def __init__(self,id,title,Session, smtpserver): self.id=id self.title=title self._Session=Session self.composers=Composers() + self.smtpserver = smtpserver MyLogons=Logons() @@ -1296,6 +1305,7 @@ ID, self.title, self._Session, + self.smtpserver, ) NewWorldPilot.aq_parent=self p=Permission('View', WorldPilot.publicmethods, NewWorldPilot) @@ -1602,7 +1612,7 @@ CcList,CcHeader=self.composeAddressListHeader(ComposeMsg.MsgEnvelope.EnvCc) BccList,BccHeader=self.composeAddressListHeader(ComposeMsg.MsgEnvelope.EnvBcc) FromList,FromHeader=self.composeAddressListHeader(ComposeMsg.MsgEnvelope.EnvFrom) - Smtp=WPSmtp('localhost',25) + Smtp=WPSmtp(self.smtpserver,25) Msgs=[] @@ -1907,10 +1917,10 @@ ('View',('','menu','prog','logonhtml'),('Anonymous','Manager')), ) - def __init__(self,id,title,user):#,question,choices): + def __init__(self,id,title,user,smtpserver):#,question,choices): self.id=id self.title=title - self.mail=WorldPilotMail('mail','Mail',self) + self.mail=WorldPilotMail('mail','Mail',self,smtpserver) # create user storage if necessary WorldPilot.storage.user.getUserStorage(user) #link to main storage @@ -2125,20 +2135,13 @@ ('View',('','menu','prog','logonhtml'),('Anonymous','Manager')), ) - def __init__(self,id,title,question,choices): + def __init__(self,id,title,imapserver,smtpserver): self.id=id self.title=title - self.question=question - self.choices=choices - self.clear_votes() + self.imapserver=imapserver + self.smtpserver=smtpserver self.composers=Composers() - def clear_votes(self): - "Delete all the votes" - self.votes={} - for choice in range(len(self.choices)): - self.votes[choice]=0 - MyLogons=Logons() prog__roles__=None @@ -2174,7 +2177,7 @@ def logon(self, REQUEST=None): "logs on" - return WorldPilot.sessions.createWorldPilotSession(self, None, REQUEST) + return WorldPilot.sessions.createWorldPilotSession(self, None, self.imapserver, self.smtpserver, REQUEST) if REQUEST.has_key('User') and REQUEST.has_key('Passwd'): thisLogon=Logon(REQUEST['User'], REQUEST['Passwd'], "172") if thisLogon.check(): @@ -2257,12 +2260,12 @@ addWorldPilotForm=HTMLFile('worldpilotAdd',globals()) -def addWorldPilot(self,id,title,question,answers,REQUEST=None): +def addWorldPilot(self,id,title,imapserver, smtpserver, REQUEST=None): """Create a worldpilot and install it in its parent Folder" The argument 'self' will be bound to the parent Folder. """ - worldpilot=WorldPilot(id, title, question, answers) + worldpilot=WorldPilot(id, title, imapserver, smtpserver) self._setObject(id, worldpilot) if REQUEST is not None: return self.manage_main(self,REQUEST) Index: worldpilotAdd.dtml =================================================================== RCS file: /cvsroot/WorldPilot/worldpilotAdd.dtml,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 worldpilotAdd.dtml --- worldpilotAdd.dtml 2000/01/28 05:35:52 1.1.1.1 +++ worldpilotAdd.dtml 2000/01/31 04:33:03 @@ -22,18 +22,18 @@ - Poll Question + IMAP Server - + - - Poll Answers
(one per line) + SMTP Server - + +