Subversion Repositories SmartDukaan

Rev

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_table
    It calls a method init() so that when one needs to access the helper methods of 
    this class to access database, the database tables are in the scope 
    """
    init()

def set_code_word(key,value,description):
    """
    Documentation for method set_code_word 
    This 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 description
        cw.value = value
        cw.description = description
    except:
        cw = code_words()
        cw.key = key
        cw.value = value
        cw.description = description
    session.commit()
    
def get_code_word_byId(id):
    """
    Documentation for method get_code_word_byId 
    This 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 cw
   
def get_code_word(key):
    """
    Documentation for method get_code_word 
    This 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.value
        print key
        print cw
    except:
        cw = "EMPTY"
    return cw

def get_allcode_words(key):
    """
    Documentation for method get_allcode_words 
    This 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 cw

def get_code_word_byKey(key):
    """
    Documentation for method get_code_word_byKey 
    This 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