def elab(v): if isinstance(v,dict): if v.has_key('proc'): obj = '' if v['proc'] == 'lispy' and v.has_key('source'): obj = lispy.execute(v['source'], { 'req': { 'args': flask.request.args, 'form': flask.request.form}}) elif v['proc'] == 'jinja' and v.has_key('source'): obj = flask.render_template_string(v['source'], title=title, data=data, req={ 'args': flask.request.args, 'form': flask.request.form}) ## elif v['proc'] == 'csv' and v.has_key('source'): ## fieldnames = v['fieldnames'] ## src = v['source'].split('\n') ## obj = [] ## for row in csv.reader(src): ## ob = {} ## for i,name in enumerate(fieldnames): ## ob[name] = row[i] ## obj.append(ob) return obj elif v.has_key('source'): return v['source']
def get(self, _id): import lispy l = mongo.db._lib.find_one(_id) return lispy.execute(l['src']) if l else ''
def post(self): import lispy data = request.get_data() rslt = lispy.execute(data) #print data, '=>', rslt return rslt