view av_settings.py @ 508:64f8666690d8

README update (Logical change 1.149)
author optonline.net!jeffpc
date Fri, 16 Jan 2004 02:53:48 +0000
parents 524a0baf7f24
children 903781c081b7
line wrap: on
line source

#/*
# * AV Admin - Helps to manage an AV department
# *
# * Copyright (C) 2003, 2004 Josef "Jeff" Sipek
# *
# * This program is free software; you can redistribute it and/or modify
# * it under the terms of the GNU General Public License as published by
# * the Free Software Foundation; either version 2 of the License, or
# * (at your option) any later version.
# *
# * This program is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# * GNU General Public License for more details.
# *
# * You should have received a copy of the GNU General Public License
# * along with this program; if not, write to the Free Software
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# *
# * $Id$
# */

def getSetting(conn,name):
	""" Returns string from the db
	
	returns string """
	dbid = conn.db.newid()
	dbid.execute("SELECT `value` FROM `settings` WHERE `name`=\"" + name + "\";")
	value = dbid.fetchone()[0] # FIXME: this should be checked

	return value

def setSetting(conn,name,value):
	""" Sets name to value in DB
	
	does not return anything """
	dbid = conn.db.newid()
	if (getSetting(conn,name)):
		dbid.execute("UPDATE `settings` SET `value`=\"" + conn.utils.sqlify(value) + "\" WHERE `name`=\"" + conn.utils.sqlify(name) + "\";")
	else:
		dbid.execute("INSERT INTO `settings` (`id`, `name`, `value`) VALUES (NULL, \"" + conn.utils.sqlify(name) + "\", \"" + conn.utils.sqlify(value) + "\");")

if __name__ == "__main__":
	print "ERROR"