def entryupdate(dictID, user, dictDB, configs): adjustedEntryID, adjustedXml, changed, feedback = ops.updateEntry( dictDB, configs, request.forms.id, request.forms.content, user["email"], {}) html = "" if configs["xemplate"].get("_xsl") and configs["xemplate"]["_xsl"] != "": import lxml.etree as ET dom = ET.XML(adjustedXml.encode("utf-8")) xslt = ET.XML(configs["xemplate"]["_xsl"].encode("utf-8")) html = str(ET.XSLT(xslt)(dom)) elif configs["xemplate"].get("_css") and configs["xemplate"]["_xsl"] != "": html = adjustedXml else: entrydata = re.sub(r"'", "\\'", adjustedXml) entrydata = re.sub(r"[\n\r]", "", entrydata) html = "<script type='text/javascript'>$('#viewer').html(Xemplatron.xml2html('" + entrydata + "', " + json.dumps( configs["xemplate"]) + ", " + json.dumps( configs["xema"]) + "));</script>" result = { "success": True, "id": adjustedEntryID, "content": adjustedXml, "contentHtml": html } if len(configs['subbing']) > 0: ops.refresh(dictDB, dictID, configs) if feedback: result["feedback"] = feedback return result
def resavejson(dictID, user, dictDB, configs): count = 0 stats = ops.getDictStats(dictDB) while stats["needResave"] and count <= 127: ops.refac(dictDB, dictID, configs) ops.refresh(dictDB, dictID, configs) ops.resave(dictDB, dictID, configs) stats = ops.getDictStats(dictDB) count += 1 return {"todo": stats["needResave"]}