def execute(self): web.header("Content-Type", "application/x-javascript") translations = {} langs = conf.get_supported_languages() for lang in langs: results = i18n.fetch_i18ns(locale=lang, return_dic=True) translations[lang] = results js = "var I18N = {" js += "translations : %s," % jsonutil.to_json(translations) js += "defaultLanguage : '%s'" % conf.get_preferred_language() js += "};" js += "var G_VERSION='%s';" % conf.G_VERSION js += "var EMPTY_UID=%d;" % model.EMPTY_UID js += "var LOGIN_USER=%s;" % jsonutil.to_json(session.get_token().to_dict()) js += conf.dynamicjs_hook() return js
def add_trigger(self, req_json): self.validation_service.validate_json("trigger-request-add", req_json) trigger_request = jsonutil.parse_json(req_json) trigger = build_trigger(trigger_request) trigger.tags.append(TRIGGER_SERVICE_TAG) trig_json = jsonutil.to_json(trigger) self.validation_service.validate_json("trigger", json) self.queue_service.send(self.topic, trig_json) return trigger
def to_json(self, wrapper=True): jsonstr = jsonutil.to_json(self.to_dict(), wrapper) jsonstr = base64.b64encode(jsonstr) return jsonstr