Rev 238 | Rev 274 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 02-Jun-2010@author: gaurav'''from elixir import *from datastore.DataCodeDefinition import *def initialize_table():"""Documentation for method initialize_tableIt calls a method init() so that when one needs to access the helper methods ofthis class to access database, the database tables are in the scope"""init()def set_code_word(key,value,description):"""Documentation for method set_code_wordThis method is used to set a code_word through input from form"""try:cw = code_words.query.filter_by(key=key).one()#print value#print descriptioncw.value = valuecw.description = descriptionexcept:cw = code_words()cw.key = keycw.value = valuecw.description = descriptionsession.commit()def get_code_word_byId(id):"""Documentation for method get_code_word_byIdThis method is used to retrieve a code_word given its id"""try:cw = code_words.query.filter_by(id=id).one()except:cw = "EMPTY"return cwdef get_code_word(key):"""Documentation for method get_code_wordThis method is used to retrieve the value of a code_word given its key i.e name"""try:cw = code_words.query.filter_by(key=key).one()cw = cw.valueprint keyprint cwexcept:cw = "EMPTY"return cwdef get_allcode_words(key):"""Documentation for method get_allcode_wordsThis method is used to retrieve all the code_words given the key i.e name"""try:cw = code_words.query.all()except:cw = "EMPTY"return cwdef get_code_word_byKey(key):"""Documentation for method get_code_word_byKeyThis method is used to retrieve the code_word given its key i.e name"""try:cw = code_words.query.filter_by(key=key).one()except:cw = "EMPTY"return cw