Beispiel #1
0
 def POST(self,text):
     if web.ctx.session.login==True:
         num = int(text.split('--')[1])
         tablename = text.split('--')[0]
         f = DynamicForm()
         custom_form(f,num)
         if not f.validates():
             msg = ERR_COL_EDIT
             return web.template.render('templates/',base='base',globals={'session':web.ctx.session}).columns(f,msg)
         else:
             fnames = [models.any2str(f["name" + str(i)].value) for i in range(num)]
             fattrs = [models.any2str(f["attr" + str(i)].value) for i in range(num)]
             attrs = {models.any2str('PK'):models.any2str(f["primarykey"].value)}
             msg = models.create_table(models.any2str(tablename),fnames,fattrs,attrs)
             if msg!='':
                 return web.template.render('templates/',base='base',globals={'session':web.ctx.session}).columns(f,msg)
             else:
                 raise web.seeother('/../')
     else:
         raise web.seeother("/../")
Beispiel #2
0
 def POST(self,text):
     text = any2str(text)
     flist,msg = models.get_fields_name(text)
     f = DynamicForm()
     custom_master(f,flist)
     if not f.validates() or msg != '':
         msg = ERR_NOTNULL
         return web.template.render('templates/',base='base',globals={'session':web.ctx.session}).master_data(f,msg)
     else :
         tbinfo = [text]
         fw = web.input()
         mflist = [any2str(flist[idx]) for idx in range(len(flist)) if fw.has_key(str(idx))]
         tbinfo.append(','.join(mflist))
         print tbinfo[1]
         msg = models.insert_column(config.MDM,tbinfo,('text','text'))
         models.db.commit()
         if msg != '':
             return web.template.render('templates/',base='base',globals={'session':web.ctx.session}).master_data(f,msg)
         else :
             raise web.seeother('/../')