Subversion Repositories SmartDukaan

Rev

Rev 238 | Rev 274 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 238 Rev 264
Line 6... Line 6...
6
 
6
 
7
from elixir import *
7
from elixir import *
8
from datastore.DataCodeDefinition import *
8
from datastore.DataCodeDefinition import *
9
 
9
 
10
def initialize_table():
10
def initialize_table():
-
 
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
    """
11
    init()
16
    init()
-
 
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()
12
    
35
    
13
def get_code_word_byId(id):
36
def get_code_word_byId(id):
-
 
37
    """
-
 
38
    Documentation for method get_code_word_byId 
-
 
39
    This method is used to retrieve a code_word given its id
-
 
40
    """
14
    try:
41
    try:
15
        cw = code_words.query.filter_by(id=id).one()
42
        cw = code_words.query.filter_by(id=id).one()
16
    except:
43
    except:
17
        cw = "EMPTY"
44
        cw = "EMPTY"
18
    return cw
45
    return cw
19
   
46
   
20
def get_code_word(key):
47
def get_code_word(key):
-
 
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
    """
21
    try:
52
    try:
22
        cw = code_words.query.filter_by(key=key).one()
53
        cw = code_words.query.filter_by(key=key).one()
23
        cw = cw.value
54
        cw = cw.value
24
        print key
55
        print key
25
        print cw
56
        print cw
26
    except:
57
    except:
27
        cw = "EMPTY"
58
        cw = "EMPTY"
28
    return cw
59
    return cw
29
 
60
 
30
def get_allcode_words(key):
61
def get_allcode_words(key):
-
 
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
    """
31
    try:
66
    try:
32
        cw = code_words.query.all()
67
        cw = code_words.query.all()
33
    except:
68
    except:
34
        cw = "EMPTY"
69
        cw = "EMPTY"
35
    return cw
70
    return cw
36
 
71
 
37
def get_code_word_byKey(key):
72
def get_code_word_byKey(key):
-
 
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
    """
38
    try:
77
    try:
39
        cw = code_words.query.filter_by(key=key).one()
78
        cw = code_words.query.filter_by(key=key).one()
40
    except:
79
    except:
41
        cw = "EMPTY"
80
        cw = "EMPTY"
42
    return cw
81
    return cw
43
 
-
 
44
 
-
 
45
def set_code_word(key,value,description):
-
 
46
    try:
-
 
47
        cw = code_words.query.filter_by(key=key).one()
-
 
48
        #print value
-
 
49
        #print description
-
 
50
        cw.value = value
-
 
51
        cw.description = description
-
 
52
    except:
-
 
53
        cw = code_words()
-
 
54
        cw.key = key
-
 
55
        cw.value = value
-
 
56
        cw.description = description
-
 
57
    session.commit()    
-
 
58
 
-
 
59
    
-
 
60
82