Handle building of MYSQL_RED_PAGE objects
This commit is contained in:
40
red_page.py
40
red_page.py
@@ -1,3 +1,4 @@
|
||||
from mysql_red import MYSQL_RED_PAGE
|
||||
|
||||
class RED_PAGE:
|
||||
"""Class for handling redundance discussion pages and archives"""
|
||||
@@ -8,5 +9,42 @@ class RED_PAGE:
|
||||
|
||||
@param page page
|
||||
"""
|
||||
|
||||
# Safe the pywikibot page object
|
||||
self.page = page
|
||||
|
||||
self.__handle_db( )
|
||||
|
||||
# if( self._mysql_page ):
|
||||
|
||||
# self.is_page_changed()
|
||||
|
||||
# else:
|
||||
# self.__mysql.add_page()
|
||||
|
||||
return
|
||||
def __handle_db( self ):
|
||||
"""
|
||||
Handles opening of db connection
|
||||
"""
|
||||
# We need a connection to our mysqldb
|
||||
self.__mysql = MYSQL_RED_PAGE( self.page._pageid )
|
||||
|
||||
if not self.__mysql.data:
|
||||
self.__mysql.add_page( self.page.title, self.page._revid )
|
||||
|
||||
def is_page_changed( self ):
|
||||
"""
|
||||
Check wether the page was changed since last run
|
||||
"""
|
||||
if( self._mysql_page[ 'rev_id' ] != self.page._revid ):
|
||||
changed_rev_id = True
|
||||
self._mysql_page[ 'rev_id' ] = self.page._revid
|
||||
|
||||
if( self._mysql_page[ 'page_title' ] != self.page.title ):
|
||||
changed_title = True
|
||||
self._mysql_page[ 'page_title' ] = self.page.title
|
||||
|
||||
if( changed_rev_id or changed_title ):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user