<s> import MySQLdb <EOL> import time <EOL> from mimify import mime_encode_header , mime_decode_header <EOL> import re <EOL> import settings <EOL> import mime <EOL> import strutil <EOL> import smtplib <EOL> import md5 <EOL> q_quote_multiline = re . compile ( "<STR_LIT>" , re . M | re . S ) <EOL> doubleline_regexp = re . compile ( "<STR_LIT>" , re . M ) <EOL> singleline_regexp = re . compile ( "<STR_LIT>" , re . M ) <EOL> from_regexp = re . compile ( "<STR_LIT>" , re . M ) <EOL> subject_regexp = re . compile ( "<STR_LIT>" , re . M ) <EOL> references_regexp = re . compile ( "<STR_LIT>" , re . M ) <EOL> lines_regexp = re . compile ( "<STR_LIT>" , re . M ) <EOL> moderator_regexp = re . compile ( "<STR_LIT>" , re . M ) <EOL> url_regexp = re . compile ( "<STR_LIT>" , re . M ) <EOL> admin_regexp = re . compile ( "<STR_LIT>" , re . M ) <EOL> server_regexp = re . compile ( "<STR_LIT>" , re . M ) <EOL> mail_code_regexp = re . compile ( "<STR_LIT>" , re . M ) <EOL> class Papercut_Storage : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . conn = MySQLdb . connect ( host = settings . dbhost , db = settings . dbname , user = settings . dbuser , passwd = settings . dbpass ) <EOL> self . cursor = self . conn . cursor ( ) <EOL> def get_message_body ( self , headers ) : <EOL> """<STR_LIT>""" <EOL> return mime . get_text_message ( headers ) <EOL> def quote_string ( self , text ) : <EOL> """<STR_LIT>""" <EOL> return text . replace ( "<STR_LIT:'>" , "<STR_LIT>" ) <EOL> def group_exists ( self , group_name ) : <EOL> stmt = """<STR_LIT>""" % ( group_name ) <EOL> self . cursor . execute ( stmt ) <EOL> return self . cursor . fetchone ( ) [ <NUM_LIT:0> ] <EOL> def article_exists ( self , group_name , style , range ) : <EOL> table_name = self . get_table_name ( group_name ) <EOL> stmt = """<STR_LIT>""" % ( table_name ) <EOL> if style == '<STR_LIT>' : <EOL> stmt = "<STR_LIT>" % ( stmt , range [ <NUM_LIT:0> ] ) <EOL> if len ( range ) == <NUM_LIT:2> : <EOL> stmt = "<STR_LIT>" % ( stmt , range [ <NUM_LIT:1> ] ) <EOL> else : <EOL> stmt = "<STR_LIT>" % ( stmt , range [ <NUM_LIT:0> ] ) <EOL> self . cursor . execute ( stmt ) <EOL> return self . cursor . fetchone ( ) [ <NUM_LIT:0> ] <EOL> def get_first_article ( self , group_name ) : <EOL> table_name = self . get_table_name ( group_name ) <EOL> stmt = """<STR_LIT>""" % ( table_name ) <EOL> num_rows = self . cursor . execute ( stmt ) <EOL> return self . cursor . fetchone ( ) [ <NUM_LIT:0> ] <EOL> def get_group_stats ( self , group_name ) : <EOL> total , max , min = self . get_table_stats ( self . get_table_name ( group_name ) ) <EOL> return ( total , min , max , group_name ) <EOL> def get_table_stats ( self , table_name ) : <EOL> stmt = """<STR_LIT>""" % ( table_name ) <EOL> num_rows = self . cursor . execute ( stmt ) <EOL> return self . cursor . fetchone ( ) <EOL> def get_table_name ( self , group_name ) : <EOL> stmt = """<STR_LIT>""" % ( group_name . replace ( '<STR_LIT:*>' , '<STR_LIT:%>' ) ) <EOL> self . cursor . execute ( stmt ) <EOL> return self . cursor . fetchone ( ) [ <NUM_LIT:0> ] <EOL> def get_message_id ( self , msg_num , group ) : <EOL> return '<STR_LIT>' % ( msg_num , group ) <EOL> def get_notification_emails ( self , forum_id ) : <EOL> fp = open ( "<STR_LIT>" % ( settings . phorum_settings_path , forum_id ) , "<STR_LIT:r>" ) <EOL> content = fp . read ( ) <EOL> fp . close ( ) <EOL> recipients = [ ] <EOL> mod_code = moderator_regexp . search ( content , <NUM_LIT:0> ) . groups ( ) <EOL> if mod_code [ <NUM_LIT:2> ] == '<STR_LIT:r>' or mod_code [ <NUM_LIT:2> ] == '<STR_LIT:a>' : <EOL> stmt = """<STR_LIT>""" % ( forum_id ) <EOL> self . cursor . execute ( stmt ) <EOL> result = list ( self . cursor . fetchall ( ) ) <EOL> for row in result : <EOL> recipients . append ( row [ <NUM_LIT:0> ] ) <EOL> return recipients <EOL> def send_notifications ( self , group_name , msg_id , thread_id , parent_id , msg_author , msg_email , msg_subject , msg_body ) : <EOL> msg_tpl = """<STR_LIT>""" <EOL> stmt = """<STR_LIT>""" % ( group_name ) <EOL> self . cursor . execute ( stmt ) <EOL> forum_id , forum_name = self . cursor . fetchone ( ) <EOL> fp = open ( "<STR_LIT>" % ( settings . phorum_settings_path ) , "<STR_LIT:r>" ) <EOL> content = fp . read ( ) <EOL> fp . close ( ) <EOL> phorum_url = url_regexp . search ( content , <NUM_LIT:0> ) . groups ( ) [ <NUM_LIT:2> ] <EOL> phorum_admin_url = admin_regexp . search ( content , <NUM_LIT:0> ) . groups ( ) [ <NUM_LIT:2> ] <EOL> phorum_server_hostname = server_regexp . search ( content , <NUM_LIT:0> ) . groups ( ) [ <NUM_LIT:3> ] <EOL> smtp = smtplib . SMTP ( '<STR_LIT:localhost>' ) <EOL> emails = self . get_notification_emails ( forum_id ) <EOL> for recipient in emails : <EOL> current_msg = msg_tpl % vars ( ) <EOL> smtp . sendmail ( "<STR_LIT>" % ( recipient ) , recipient , current_msg ) <EOL> phorum_mail_code = mail_code_regexp . search ( content , <NUM_LIT:0> ) . groups ( ) [ <NUM_LIT:3> ] <EOL> notification_mail_tpl = """<STR_LIT>""" <EOL> stmt = """<STR_LIT>""" % ( forum_id ) <EOL> num_rows = self . cursor . execute ( stmt ) <EOL> if num_rows == <NUM_LIT:1> : <EOL> email_list , email_return = self . cursor . fetchone ( ) <EOL> msg_body = strutil . wrap ( msg_body ) <EOL> if len ( msg_email ) > <NUM_LIT:0> : <EOL> msg_email = '<STR_LIT>' % msg_email <EOL> else : <EOL> msg_email = '<STR_LIT>' <EOL> random_msgid = md5 . new ( str ( time . clock ( ) ) ) . hexdigest ( ) <EOL> from papercut import __VERSION__ <EOL> phorum_version = settings . phorum_version <EOL> current_msg = notification_mail_tpl % vars ( ) <EOL> smtp . sendmail ( '<STR_LIT>' % ( msg_author , msg_email ) , email_list , current_msg ) <EOL> smtp . quit ( ) <EOL> def get_NEWGROUPS ( self , ts , group = '<STR_LIT:%>' ) : <EOL> return None <EOL> def get_NEWNEWS ( self , ts , group = '<STR_LIT:*>' ) : <EOL> stmt = """<STR_LIT>""" % ( group_name . replace ( '<STR_LIT:*>' , '<STR_LIT:%>' ) ) <EOL> self . cursor . execute ( stmt ) <EOL> result = list ( self . cursor . fetchall ( ) ) <EOL> articles = [ ] <EOL> for group , table in result : <EOL> stmt = """<STR_LIT>""" % ( table , ts ) <EOL> num_rows = self . cursor . execute ( stmt ) <EOL> if num_rows == <NUM_LIT:0> : <EOL> continue <EOL> ids = list ( self . cursor . fetchall ( ) ) <EOL> for id in ids : <EOL> articles . append ( "<STR_LIT>" % ( id , group ) ) <EOL> if len ( articles ) == <NUM_LIT:0> : <EOL> return '<STR_LIT>' <EOL> else : <EOL> return "<STR_LIT:\r\n>" . join ( articles ) <EOL> def get_GROUP ( self , group_name ) : <EOL> table_name = self . get_table_name ( group_name ) <EOL> result = self . get_table_stats ( table_name ) <EOL> return ( result [ <NUM_LIT:0> ] , result [ <NUM_LIT:2> ] , result [ <NUM_LIT:1> ] ) <EOL> def get_LIST ( self , username = "<STR_LIT>" ) : <EOL> stmt = """<STR_LIT>""" <EOL> self . cursor . execute ( stmt ) <EOL> result = list ( self . cursor . fetchall ( ) ) <EOL> if len ( result ) == <NUM_LIT:0> : <EOL> return "<STR_LIT>" <EOL> else : <EOL> lists = [ ] <EOL> for group_name , table in result : <EOL> total , maximum , minimum = self . get_table_stats ( table ) <EOL> if settings . server_type == '<STR_LIT>' : <EOL> lists . append ( "<STR_LIT>" % ( group_name , maximum , minimum ) ) <EOL> else : <EOL> lists . append ( "<STR_LIT>" % ( group_name , maximum , minimum ) ) <EOL> return "<STR_LIT:\r\n>" . join ( lists ) <EOL> def get_STAT ( self , group_name , id ) : <EOL> table_name = self . get_table_name ( group_name ) <EOL> stmt = """<STR_LIT>""" % ( table_name , id ) <EOL> return self . cursor . execute ( stmt ) <EOL> def get_ARTICLE ( self , group_name , id ) : <EOL> table_name = self . get_table_name ( group_name ) <EOL> stmt = """<STR_LIT>""" % ( table_name , table_name , id ) <EOL> num_rows = self . cursor . execute ( stmt ) <EOL> if num_rows == <NUM_LIT:0> : <EOL> return None <EOL> result = list ( self . cursor . fetchone ( ) ) <EOL> if len ( result [ <NUM_LIT:2> ] ) == <NUM_LIT:0> : <EOL> author = result [ <NUM_LIT:1> ] <EOL> else : <EOL> author = "<STR_LIT>" % ( result [ <NUM_LIT:1> ] , result [ <NUM_LIT:2> ] ) <EOL> formatted_time = strutil . get_formatted_time ( time . localtime ( result [ <NUM_LIT:4> ] ) ) <EOL> headers = [ ] <EOL> headers . append ( "<STR_LIT>" % ( settings . nntp_hostname ) ) <EOL> headers . append ( "<STR_LIT>" % ( author ) ) <EOL> headers . append ( "<STR_LIT>" % ( group_name ) ) <EOL> headers . append ( "<STR_LIT>" % ( formatted_time ) ) <EOL> headers . append ( "<STR_LIT>" % ( result [ <NUM_LIT:3> ] ) ) <EOL> headers . append ( "<STR_LIT>" % ( result [ <NUM_LIT:0> ] , group_name ) ) <EOL> headers . append ( "<STR_LIT>" % ( settings . nntp_hostname , group_name , result [ <NUM_LIT:0> ] ) ) <EOL> if result [ <NUM_LIT:6> ] != <NUM_LIT:0> : <EOL> headers . append ( "<STR_LIT>" % ( result [ <NUM_LIT:6> ] , group_name ) ) <EOL> return ( "<STR_LIT:\r\n>" . join ( headers ) , strutil . format_body ( result [ <NUM_LIT:5> ] ) ) <EOL> def get_LAST ( self , group_name , current_id ) : <EOL> table_name = self . get_table_name ( group_name ) <EOL> stmt = """<STR_LIT>""" % ( table_name , current_id ) <EOL> num_rows = self . cursor . execute ( stmt ) <EOL> if num_rows == <NUM_LIT:0> : <EOL> return None <EOL> return self . cursor . fetchone ( ) [ <NUM_LIT:0> ] <EOL> def get_NEXT ( self , group_name , current_id ) : <EOL> table_name = self . get_table_name ( group_name ) <EOL> stmt = """<STR_LIT>""" % ( table_name , current_id ) <EOL> num_rows = self . cursor . execute ( stmt ) <EOL> if num_rows == <NUM_LIT:0> : <EOL> return None <EOL> return self . cursor . fetchone ( ) [ <NUM_LIT:0> ] <EOL> def get_HEAD ( self , group_name , id ) : <EOL> table_name = self . get_table_name ( group_name ) <EOL> stmt = """<STR_LIT>""" % ( table_name , id ) <EOL> num_rows = self . cursor . execute ( stmt ) <EOL> if num_rows == <NUM_LIT:0> : <EOL> return None <EOL> result = list ( self . cursor . fetchone ( ) ) <EOL> if len ( result [ <NUM_LIT:2> ] ) == <NUM_LIT:0> : <EOL> author = result [ <NUM_LIT:1> ] <EOL> else : <EOL> author = "<STR_LIT>" % ( result [ <NUM_LIT:1> ] , result [ <NUM_LIT:2> ] ) <EOL> formatted_time = strutil . get_formatted_time ( time . localtime ( result [ <NUM_LIT:4> ] ) ) <EOL> headers = [ ] <EOL> headers . append ( "<STR_LIT>" % ( settings . nntp_hostname ) ) <EOL> headers . append ( "<STR_LIT>" % ( author ) ) <EOL> headers . append ( "<STR_LIT>" % ( group_name ) ) <EOL> headers . append ( "<STR_LIT>" % ( formatted_time ) ) <EOL> headers . append ( "<STR_LIT>" % ( result [ <NUM_LIT:3> ] ) ) <EOL> headers . append ( "<STR_LIT>" % ( result [ <NUM_LIT:0> ] , group_name ) ) <EOL> headers . append ( "<STR_LIT>" % ( settings . nntp_hostname , group_name , result [ <NUM_LIT:0> ] ) ) <EOL> if result [ <NUM_LIT:5> ] != <NUM_LIT:0> : <EOL> headers . append ( "<STR_LIT>" % ( result [ <NUM_LIT:5> ] , group_name ) ) <EOL> return "<STR_LIT:\r\n>" . join ( headers ) <EOL> def get_BODY ( self , group_name , id ) : <EOL> table_name = self . get_table_name ( group_name ) <EOL> stmt = """<STR_LIT>""" % ( table_name , table_name , id ) <EOL> num_rows = self . cursor . execute ( stmt ) <EOL> if num_rows == <NUM_LIT:0> : <EOL> return None <EOL> else : <EOL> return strutil . format_body ( self . cursor . fetchone ( ) [ <NUM_LIT:0> ] ) <EOL> def get_XOVER ( self , group_name , start_id , end_id = '<STR_LIT>' ) : <EOL> table_name = self . get_table_name ( group_name ) <EOL> stmt = """<STR_LIT>""" % ( table_name , table_name , start_id ) <EOL> if end_id != '<STR_LIT>' : <EOL> stmt = "<STR_LIT>" % ( stmt , end_id ) <EOL> self . cursor . execute ( stmt ) <EOL> result = list ( self . cursor . fetchall ( ) ) <EOL> overviews = [ ] <EOL> for row in result : <EOL> if row [ <NUM_LIT:3> ] == '<STR_LIT>' : <EOL> author = row [ <NUM_LIT:2> ] <EOL> else : <EOL> author = "<STR_LIT>" % ( row [ <NUM_LIT:2> ] , row [ <NUM_LIT:3> ] ) <EOL> formatted_time = strutil . get_formatted_time ( time . localtime ( row [ <NUM_LIT:5> ] ) ) <EOL> message_id = "<STR_LIT>" % ( row [ <NUM_LIT:0> ] , group_name ) <EOL> line_count = len ( row [ <NUM_LIT:6> ] . split ( '<STR_LIT:\n>' ) ) <EOL> xref = '<STR_LIT>' % ( settings . nntp_hostname , group_name , row [ <NUM_LIT:0> ] ) <EOL> if row [ <NUM_LIT:1> ] != <NUM_LIT:0> : <EOL> reference = "<STR_LIT>" % ( row [ <NUM_LIT:1> ] , group_name ) <EOL> else : <EOL> reference = "<STR_LIT>" <EOL> overviews . append ( "<STR_LIT>" % ( row [ <NUM_LIT:0> ] , row [ <NUM_LIT:4> ] , author , formatted_time , message_id , reference , len ( strutil . format_body ( row [ <NUM_LIT:6> ] ) ) , line_count , xref ) ) <EOL> return "<STR_LIT:\r\n>" . join ( overviews ) <EOL> def get_XPAT ( self , group_name , header , pattern , start_id , end_id = '<STR_LIT>' ) : <EOL> table_name = self . get_table_name ( group_name ) <EOL> stmt = """<STR_LIT>""" % ( table_name , table_name , header , strutil . format_wildcards ( pattern ) , start_id ) <EOL> if end_id != '<STR_LIT>' : <EOL> stmt = "<STR_LIT>" % ( stmt , end_id ) <EOL> num_rows = self . cursor . execute ( stmt ) <EOL> if num_rows == <NUM_LIT:0> : <EOL> return None <EOL> result = list ( self . cursor . fetchall ( ) ) <EOL> hdrs = [ ] <EOL> for row in result : <EOL> if header . upper ( ) == '<STR_LIT>' : <EOL> hdrs . append ( '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , row [ <NUM_LIT:4> ] ) ) <EOL> elif header . upper ( ) == '<STR_LIT>' : <EOL> hdrs . append ( '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , row [ <NUM_LIT:2> ] , row [ <NUM_LIT:3> ] ) ) <EOL> elif header . upper ( ) == '<STR_LIT>' : <EOL> hdrs . append ( '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , strutil . get_formatted_time ( time . localtime ( result [ <NUM_LIT:5> ] ) ) ) ) <EOL> elif header . upper ( ) == '<STR_LIT>' : <EOL> hdrs . append ( '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , row [ <NUM_LIT:0> ] , group_name ) ) <EOL> elif ( header . upper ( ) == '<STR_LIT>' ) and ( row [ <NUM_LIT:1> ] != <NUM_LIT:0> ) : <EOL> hdrs . append ( '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , row [ <NUM_LIT:1> ] , group_name ) ) <EOL> elif header . upper ( ) == '<STR_LIT>' : <EOL> hdrs . append ( '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , len ( row [ <NUM_LIT:6> ] ) ) ) <EOL> elif header . upper ( ) == '<STR_LIT>' : <EOL> hdrs . append ( '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , len ( row [ <NUM_LIT:6> ] . split ( '<STR_LIT:\n>' ) ) ) ) <EOL> elif header . upper ( ) == '<STR_LIT>' : <EOL> hdrs . append ( '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , settings . nntp_hostname , group_name , row [ <NUM_LIT:0> ] ) ) <EOL> if len ( hdrs ) == <NUM_LIT:0> : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return "<STR_LIT:\r\n>" . join ( hdrs ) <EOL> def get_LISTGROUP ( self , group_name ) : <EOL> table_name = self . get_table_name ( group_name ) <EOL> stmt = """<STR_LIT>""" % ( table_name ) <EOL> self . cursor . execute ( stmt ) <EOL> result = list ( self . cursor . fetchall ( ) ) <EOL> return "<STR_LIT:\r\n>" . join ( [ "<STR_LIT:%s>" % k for k in result ] ) <EOL> def get_XGTITLE ( self , pattern = None ) : <EOL> stmt = """<STR_LIT>""" <EOL> if pattern != None : <EOL> stmt = stmt + """<STR_LIT>""" % ( strutil . format_wildcards ( pattern ) ) <EOL> stmt = stmt + """<STR_LIT>""" <EOL> self . cursor . execute ( stmt ) <EOL> result = list ( self . cursor . fetchall ( ) ) <EOL> return "<STR_LIT:\r\n>" . join ( [ "<STR_LIT>" % ( k , v ) for k , v in result ] ) <EOL> def get_XHDR ( self , group_name , header , style , range ) : <EOL> table_name = self . get_table_name ( group_name ) <EOL> stmt = """<STR_LIT>""" % ( table_name , table_name ) <EOL> if style == '<STR_LIT>' : <EOL> stmt = '<STR_LIT>' % ( stmt , range [ <NUM_LIT:0> ] ) <EOL> if len ( range ) == <NUM_LIT:2> : <EOL> stmt = '<STR_LIT>' % ( stmt , range [ <NUM_LIT:1> ] ) <EOL> else : <EOL> stmt = '<STR_LIT>' % ( stmt , range [ <NUM_LIT:0> ] ) <EOL> if self . cursor . execute ( stmt ) == <NUM_LIT:0> : <EOL> return None <EOL> result = self . cursor . fetchall ( ) <EOL> hdrs = [ ] <EOL> for row in result : <EOL> if header . upper ( ) == '<STR_LIT>' : <EOL> hdrs . append ( '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , row [ <NUM_LIT:4> ] ) ) <EOL> elif header . upper ( ) == '<STR_LIT>' : <EOL> hdrs . append ( '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , row [ <NUM_LIT:2> ] , row [ <NUM_LIT:3> ] ) ) <EOL> elif header . upper ( ) == '<STR_LIT>' : <EOL> hdrs . append ( '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , strutil . get_formatted_time ( time . localtime ( result [ <NUM_LIT:5> ] ) ) ) ) <EOL> elif header . upper ( ) == '<STR_LIT>' : <EOL> hdrs . append ( '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , row [ <NUM_LIT:0> ] , group_name ) ) <EOL> elif ( header . upper ( ) == '<STR_LIT>' ) and ( row [ <NUM_LIT:1> ] != <NUM_LIT:0> ) : <EOL> hdrs . append ( '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , row [ <NUM_LIT:1> ] , group_name ) ) <EOL> elif header . upper ( ) == '<STR_LIT>' : <EOL> hdrs . append ( '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , len ( row [ <NUM_LIT:6> ] ) ) ) <EOL> elif header . upper ( ) == '<STR_LIT>' : <EOL> hdrs . append ( '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , len ( row [ <NUM_LIT:6> ] . split ( '<STR_LIT:\n>' ) ) ) ) <EOL> elif header . upper ( ) == '<STR_LIT>' : <EOL> hdrs . append ( '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , settings . nntp_hostname , group_name , row [ <NUM_LIT:0> ] ) ) <EOL> if len ( hdrs ) == <NUM_LIT:0> : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return "<STR_LIT:\r\n>" . join ( hdrs ) <EOL> def do_POST ( self , group_name , lines , ip_address , username = '<STR_LIT>' ) : <EOL> table_name = self . get_table_name ( group_name ) <EOL> body = self . get_message_body ( lines ) <EOL> author , email = from_regexp . search ( lines , <NUM_LIT:0> ) . groups ( ) <EOL> subject = subject_regexp . search ( lines , <NUM_LIT:0> ) . groups ( ) [ <NUM_LIT:0> ] . strip ( ) <EOL> lines = mime_decode_header ( re . sub ( q_quote_multiline , "<STR_LIT>" , lines ) ) <EOL> if lines . find ( '<STR_LIT>' ) != - <NUM_LIT:1> : <EOL> references = references_regexp . search ( lines , <NUM_LIT:0> ) . groups ( ) <EOL> parent_id , void = references [ - <NUM_LIT:1> ] . strip ( ) . split ( '<STR_LIT:@>' ) <EOL> stmt = """<STR_LIT>""" % ( table_name ) <EOL> num_rows = self . cursor . execute ( stmt ) <EOL> if num_rows == <NUM_LIT:0> : <EOL> new_id = <NUM_LIT:1> <EOL> else : <EOL> new_id = self . cursor . fetchone ( ) [ <NUM_LIT:0> ] <EOL> stmt = """<STR_LIT>""" % ( table_name , parent_id ) <EOL> num_rows = self . cursor . execute ( stmt ) <EOL> if num_rows == <NUM_LIT:0> : <EOL> return None <EOL> parent_id , thread_id , modifystamp = self . cursor . fetchone ( ) <EOL> else : <EOL> stmt = """<STR_LIT>""" % ( table_name ) <EOL> self . cursor . execute ( stmt ) <EOL> new_id , modifystamp = self . cursor . fetchone ( ) <EOL> parent_id = <NUM_LIT:0> <EOL> thread_id = new_id <EOL> stmt = """<STR_LIT>""" % ( table_name , new_id , thread_id , parent_id , self . quote_string ( author . strip ( ) ) , self . quote_string ( subject ) , self . quote_string ( email ) , ip_address , modifystamp ) <EOL> if not self . cursor . execute ( stmt ) : <EOL> return None <EOL> else : <EOL> stmt = """<STR_LIT>""" % ( table_name , new_id , self . quote_string ( body ) , thread_id ) <EOL> if not self . cursor . execute ( stmt ) : <EOL> stmt = """<STR_LIT>""" % ( table_name , new_id ) <EOL> self . cursor . execute ( stmt ) <EOL> return None <EOL> else : <EOL> self . send_notifications ( group_name , new_id , thread_id , parent_id , author . strip ( ) , email , subject , body ) <EOL> return <NUM_LIT:1> </s>
