Logo Search packages:      
Sourcecode: mbot version File versions  Download package

def MyNewsHandler::MyNewsHandler::add_img (   self,
  filename,
  filetype,
  filedata,
  TNfiledata,
  filesize 
)

Add an image in the database 

Definition at line 51 of file MyNewsHandler.py.

00051                                                                          :
        """ Add an image in the database """
        
        self.log.notice("[MyNewsHandler]: add_img")
        news_id   = self.id
        desc      = "[News] " + filename

        myquery = """
        INSERT INTO %s (description, img_data, tnimg_data,
                        filename, filesize, filetype)
         VALUES ('%s','%s','%s','%s','%d','%s')
         """ % (self.photo_tbl, desc, db.escape_string(filedata),
                db.escape_string(TNfiledata), filename, filesize, filetype)

        # First insert the image
        db      = self.dbconn()
        mycur     = db.cursor()
        mycur.execute(myquery)

        # Now we add the link to the image from the news table
        id      = self.getid(db, self.photo_tblsq)
        self.log.debug("[MyNewsHandler]: add_img => id='%d'" % id)
        myquery   = "UPDATE %s SET id_img='%d' WHERE id='%d'" \
                  % (self.news_tbl, id, news_id)
        mycur     = db.cursor()
        mycur.execute(myquery)
        
        db.close()
        return id
    
    


Generated by  Doxygen 1.6.0   Back to index