def s_startsession(i):
    # Check to see if session exists ? Return session data : create a new one
    # tag = Tags.select().where(Tags.id == str(hexToDec(i))).first()
    tag = Tags.select().where(Tags.id == i).first()
    if tag is not None:
        if tag.session.first() is None:
            # No session for this ID exists, create one
            s = Sessions()
            s.timeOpened = datetime.datetime.now()
            s.tag = tag
            s.save()

        # Format menu for consumption
        data = {'menu': []}
        for x in StoreItems.select().where(StoreItems.store == tag.store):
            data['menu'].append({'name': x.name, 'desc': x.desc, 'id': x.id, 'price': x.price})
        return str(dicttoxml.dicttoxml(data, ids=False))
    else:
        flash('Sorry, that tag does not exist')
        return redirect(url_for('v_index'))
def s_startsession(i):
    # Check to see if session exists ? Return session data : create a new one
    # tag = Tags.select().where(Tags.id == str(hexToDec(i))).first()
    tag = Tags.select().where(Tags.id == i).first()
    if tag is not None:
        if tag.session.first() is None:
            # No session for this ID exists, create one
            s = Sessions()
            s.timeOpened = datetime.datetime.now()
            s.tag = tag
            s.save()

        # Format menu for consumption
        data = {'menu': []}
        for x in StoreItems.select().where(StoreItems.store == tag.store):
            data['menu'].append({
                'name': x.name,
                'desc': x.desc,
                'id': x.id,
                'price': x.price
            })
        return str(dicttoxml.dicttoxml(data, ids=False))
    else:
        flash('Sorry, that tag does not exist')
        return redirect(url_for('v_index'))
def s_getsessions():
    rv = '<pre>'
    for x in Sessions.select():
        rv += 'SESSION ' + str(x.id) + '\n'
    rv += '</pre>'
    return rv
def s_getsessions():
    rv = '<pre>'
    for x in Sessions.select():
        rv += 'SESSION ' + str(x.id) + '\n'
    rv += '</pre>'
    return rv