Customization by JeanPierreFlandrois

The aim is to receive information and backup mails (and to identify the mails correctly), and to perform an on-site backup also.

On-site backup

* Forewords : you have to use also a by-mail backup, this is the way to be informed of the wiki life (and to be quiet, backup is done in two places)

from time import strftime

BACKUP_DIR = '/some/place/to/backup/' #will be changed by the wrapper
WIKI_NAME='Monkey Wiki' #each wiki clone has a name, better to identify the mails
#WIKI_NAME is the name of the wiki in case of a wiki farm
#to identify the mails send by each wiki !

#Change from this line to the end of the function
       	m['From'],m['To'],m['Subject'] = WIKI_LOGGER,WIKI_MASTER,'%s %s'%(WIKI_NAME+': '+self.page, self.action)
	
	#hacking on-site backup
	#backup directory BACKUP_DIR is defined at the beginning
	if os.path.isdir(BACKUP_DIR):
		bkp=open(os.path.join(BACKUP_DIR,self.page+strftime('%y%m%d%H%M%S')),"w")
		bkp.write(notification+'\n'+self.get_text())
		bkp.close()
	#end of the on-site backup
	server = smtplib.SMTP(SMTP_SERVER)
	#server.set_debuglevel(1)
        server.sendmail(WIKI_LOGGER, [WIKI_MASTER], m.as_string())
	
        server.quit()
	#when commenting these 3 lines backup is done locally without mail send
        

        #end of the modification 

Log file

This indeed is a very local hacking !

def main():
    print 'Content-Type: text/html; charset=iso-8859-1\n'
    try:
        print WikiPage?(**get_wp_args()).web_output()
	#--added to follow the uploads
	iplist=open(PATH_TO_WIKI_TEXT+IPUPLOADS,"a")
	teatime=time.strftime('%X %x %Z')
	iplist.write(cgi.escape(os.environ["REMOTE_ADDR"])+'#'+teatime+'#'+str(get_wp_args()).split(":")[1].split("'")[1]+'\n')
        iplist.close()
	#--
    except Exception, inst:
        print 'Error:', inst

#Definition specific to maintain a list of uploads
IPUPLOADS='A_wiki_name_like--Ip Uploads'

Sun Aug 17 11:33:56 2008

Valid CSS! PRABI image Valid CSS! [Python Powered]