Subversion Repositories SmartDukaan

Rev

Rev 203 | Rev 264 | 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():
11
    init()
12
 
203 ashish 13
def get_code_word_byId(id):
238 ashish 14
    try:
15
        cw = code_words.query.filter_by(id=id).one()
16
    except:
17
        cw = "EMPTY"
203 ashish 18
    return cw
19
 
238 ashish 20
def get_code_word(key):
21
    try:
22
        cw = code_words.query.filter_by(key=key).one()
23
        cw = cw.value
24
        print key
25
        print cw
26
    except:
27
        cw = "EMPTY"
203 ashish 28
    return cw
29
 
30
def get_allcode_words(key):
238 ashish 31
    try:
32
        cw = code_words.query.all()
33
    except:
34
        cw = "EMPTY"
203 ashish 35
    return cw
36
 
238 ashish 37
def get_code_word_byKey(key):
38
    try:
39
        cw = code_words.query.filter_by(key=key).one()
40
    except:
41
        cw = "EMPTY"
42
    return cw
203 ashish 43
 
238 ashish 44
 
203 ashish 45
def set_code_word(key,value,description):
238 ashish 46
    try:
47
        cw = code_words.query.filter_by(key=key).one()
48
        #print value
49
        #print description
203 ashish 50
        cw.value = value
51
        cw.description = description
238 ashish 52
    except:
203 ashish 53
        cw = code_words()
54
        cw.key = key
55
        cw.value = value
56
        cw.description = description
57
    session.commit()    
58
 
238 ashish 59