Subversion Repositories SmartDukaan

Rev

Rev 238 | Rev 274 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
203 ashish 1
'''
2
Created on 02-Jun-2010
3
 
4
@author: gaurav
5
'''
6
 
7
from elixir import *
8
from datastore.DataCodeDefinition import *
9
 
238 ashish 10
def initialize_table():
264 ashish 11
    """
12
    Documentation for method initialize_table
13
    It calls a method init() so that when one needs to access the helper methods of 
14
    this class to access database, the database tables are in the scope 
15
    """
238 ashish 16
    init()
264 ashish 17
 
18
def set_code_word(key,value,description):
19
    """
20
    Documentation for method set_code_word 
21
    This method is used to set a code_word through input from form
22
    """
23
    try:
24
        cw = code_words.query.filter_by(key=key).one()
25
        #print value
26
        #print description
27
        cw.value = value
28
        cw.description = description
29
    except:
30
        cw = code_words()
31
        cw.key = key
32
        cw.value = value
33
        cw.description = description
34
    session.commit()
238 ashish 35
 
203 ashish 36
def get_code_word_byId(id):
264 ashish 37
    """
38
    Documentation for method get_code_word_byId 
39
    This method is used to retrieve a code_word given its id
40
    """
238 ashish 41
    try:
42
        cw = code_words.query.filter_by(id=id).one()
43
    except:
44
        cw = "EMPTY"
203 ashish 45
    return cw
46
 
238 ashish 47
def get_code_word(key):
264 ashish 48
    """
49
    Documentation for method get_code_word 
50
    This method is used to retrieve the value of a code_word given its key i.e name
51
    """
238 ashish 52
    try:
53
        cw = code_words.query.filter_by(key=key).one()
54
        cw = cw.value
55
        print key
56
        print cw
57
    except:
58
        cw = "EMPTY"
203 ashish 59
    return cw
60
 
61
def get_allcode_words(key):
264 ashish 62
    """
63
    Documentation for method get_allcode_words 
64
    This method is used to retrieve all the code_words given the key i.e name
65
    """
238 ashish 66
    try:
67
        cw = code_words.query.all()
68
    except:
69
        cw = "EMPTY"
203 ashish 70
    return cw
71
 
238 ashish 72
def get_code_word_byKey(key):
264 ashish 73
    """
74
    Documentation for method get_code_word_byKey 
75
    This method is used to retrieve the code_word given its key i.e name
76
    """
238 ashish 77
    try:
78
        cw = code_words.query.filter_by(key=key).one()
79
    except:
80
        cw = "EMPTY"
81
    return cw