if m != 'Model' and str(type(model)) == "<class 'peewee.BaseModel'>": if model.table_exists() == False: try: model.create_table() except Exception, e: pass elif str(type(model)) == "<type 'module'>": for m2 in dir(model): model2 = getattr(model, m2) if m2 not in ('Model') and str( type(model2)) == "<class 'peewee.BaseModel'>": if model2.table_exists() == False: try: model2.create_table() except Exception, e: pass # 执行安装 if 0 == wiki.models.Role.select().count(): ar = wiki.models.Role() ar.code = 'admin' ar.name = '管理者' ar.save() ar = wiki.models.Role() ar.code = 'user' ar.name = '用户' ar.save() Database.close()
try: model.create_table() except Exception, e: pass elif str(type(model)) == "<type 'module'>": for m2 in dir(model): model2 = getattr(model, m2) if m2 not in ('Model') and str(type(model2)) == "<class 'peewee.BaseModel'>": if model2.table_exists() == False: try: model2.create_table() except Exception, e: pass # 执行安装 if 0 == wiki.models.Role.select().count(): ar = wiki.models.Role() ar.code = 'admin' ar.name = '管理者' ar.save() ar = wiki.models.Role() ar.code = 'user' ar.name = '用户' ar.save() Database.close()
def on__finish(self): # 关闭主从数据库连接 Database.close()