Change behavior of MysqlRedFam to be able to get instance without knowen fam_hash

This commit is contained in:
2015-09-19 19:49:20 +02:00
parent b5ca69077c
commit 8059bb9992
2 changed files with 7 additions and 14 deletions

View File

@@ -203,38 +203,30 @@ SET `red_page_id` = ?, `heading` = ?, `beginning` = ?, `ending` = ?, \
article0, article1, article2, article3, article4, article5, article6, \
article7 ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );'
def __init__( self, fam_hash ):
def __init__( self ):
"""
Creates a new instance, runs __init__ of parent class
"""
super().__init__( )
self.__fam_hash = fam_hash
self.data = self.get_fam()
def __del__( self ):
pass
def get_fam( self ):
def get_fam( self, fam_hash ):
"""
Retrieves a red family row from MySQL-Database for given fam_hash
@returns dict Dictionairy with data for given fam hash
False if none found
"""
self.__fam_hash = fam_hash
cursor = type( self ).connection.cursor( mysqldb.DictCursor )
cursor.execute( 'SELECT * FROM `red_families` WHERE `fam_hash` = ?;',
( self.__fam_hash, ) )
res = cursor.fetchone()
if res:
return res
else:
return False
( fam_hash, ) )
self.data = cursor.fetchone()
def add_fam( self, articlesList, heading, red_page_id,
beginning, ending=None, status=0 ):