def render(self, context): output = self.nodelist.render(context) try: _setc2Ctx(context, self.obj, DICTJSON.fromJSON(output)) except Exception as inst: milog.error("Error al convertir a JSON %s", inst) if settings.DEBUG: return "ERROR PROCESADO JSON" + output return ""
def toJSON(context, elem_cont): """ Convierte elemento a JSON """ if isinstance(elem_cont, str): obj = _c2Ctx(context, elem_cont) else: obj = elem_cont try: return DICTJSON.toJSON(obj) except: return str(obj)
def toJSON(context, elem_cont): """ Convierte elemento a JSON """ if isinstance(elem_cont, str): obj = _c2Ctx(context, elem_cont) else: obj = elem_cont try: return DICTJSON.toJSON(obj) except Exception: return str(obj)
def envDATA(context, elem_cont): """ Para Probar cosas, mostrara por pantalla usuario, conexion a BBDD... """ resul = list() try: from YBUTILS.DbRouter import dameConexionDef from django.db import connection from copy import deepcopy micon = dameConexionDef() resul.append("BBDD POR LIBRERIA--------------------------") resul.append(micon.alias) auxdict = deepcopy(micon.settings_dict) auxdict["PASSWORD"] = "******" resul.append(DICTJSON.toJSON(auxdict)) micon = dameConexionDef() resul.append("BBDD django.db.connection-------------------") micon = connection resul.append(micon.alias) auxdict = deepcopy(micon.settings_dict) auxdict["PASSWORD"] = "******" resul.append(DICTJSON.toJSON(auxdict)) except: pass try: # requiere TEMPLATE_CONTEXT_PROCESSORS=('django.core.context_processors.request',) mireq = context["request"] resul.append("HTTP HEADERS-------------------") for k, v in mireq.META.items(): try: resul.append(str(k) + "--->" + str(v)) except: pass except: pass return "<br/>".join(resul)
def envDATA(context, elem_cont): """ Para Probar cosas, mostrara por pantalla usuario, conexion a BBDD... """ resul = list() try: from YBUTILS.DbRouter import dameConexionDef from django.db import connection from copy import deepcopy micon = dameConexionDef() resul.append("BBDD POR LIBRERIA--------------------------") resul.append(micon.alias) auxdict = deepcopy(micon.settings_dict) auxdict["PASSWORD"] = "******" resul.append(DICTJSON.toJSON(auxdict)) micon = dameConexionDef() resul.append("BBDD django.db.connection-------------------") micon = connection resul.append(micon.alias) auxdict = deepcopy(micon.settings_dict) auxdict["PASSWORD"] = "******" resul.append(DICTJSON.toJSON(auxdict)) except Exception: pass try: # requiere TEMPLATE_CONTEXT_PROCESSORS=('django.core.context_processors.request',) mireq = context['request'] resul.append("HTTP HEADERS-------------------") for k, v in mireq.META.items(): try: resul.append(str(k) + "--->" + str(v)) except Exception: pass except Exception: pass return "<br/>".join(resul)
def yblogin_permissions_request(self, request): if request.method == "POST": return HttpResponseRedirect("/") reg = open(path.join(settings.PROJECT_ROOT, "config/urls.json")).read() oReg = DICTJSON.fromJSON(reg) models = {} for mod in oReg["models"]: for modelName in oReg["models"][mod]: acciones = factorias.FactoriaAccion.getAcciones(modelName, "I") models[modelName] = [] for a in acciones: models[modelName].append(a) # miaccion = factorias.FactoriaAccion.getAcciones("telsac", 'I') return render(request, "portal/permissions.html", {"models": models})
def render(self, context): output = self.nodelist.render(context) try: obj2 = DICTJSON.fromJSON(output) except Exception as inst: milog.error("Error al convertir a JSON %s", inst) if settings.DEBUG: return "ERROR PROCESADO JSON" + output isquery = True if obj2["TIPO"] == "I" or obj2["TIPO"] == "O": isquery = False context.push() aux = viewsets.YBMIXINCTXtemplate.respuestapeticionCTX( context, obj2["APLICACION"], obj2["PREFIJO"], obj2["TEMPLATE"], obj2.get("QUERYSTRING", {}), obj2.get("PK", None), isquery, obj2.get("MODIF", None), obj2.get("PARAM", None)) context.pop() return aux
def render(self, context): output = self.nodelist.render(context) try: obj2 = DICTJSON.fromJSON(output) except Exception as inst: milog.error("Error al convertir a JSON %s", inst) if settings.DEBUG: return "ERROR PROCESADO JSON" + output isquery = True if obj2["TIPO"] == "I" or obj2["TIPO"] == "O": isquery = False context.push() aux = viewsets.YBMIXINCTXtemplate.respuestapeticionCTX( context, obj2["APLICACION"], obj2["PREFIJO"], obj2["TEMPLATE"], obj2.get("QUERYSTRING", {}), obj2.get("PK", None), isquery, obj2.get("MODIF", None), ) context.pop() return aux
from os import path from AQNEXT.settings import PROJECT_ROOT from YBAQNEXT.settings import INSTALLED_APPS from YBWEB.ctxJSON import DICTJSON YEBO_APPS = () CONTROLLER_APPS = () API_APPS = () rest = open(path.join(PROJECT_ROOT, "config/urls.json")).read() oRest = DICTJSON.fromJSON(rest) for app in oRest: if "controller" in oRest[app]: CONTROLLER_APPS += (app, ) elif "api" in oRest[app]: API_APPS += (app, ) else: YEBO_APPS += (app, ) INSTALLED_APPS += YEBO_APPS INSTALLED_APPS += CONTROLLER_APPS INSTALLED_APPS += API_APPS # INSTALLED_APPS += ('channels', )
def test_fromJSON(self): str_json = '{"a": "b", "c": {"d": "e"}}' json = OrderedDict([('a', 'b'), ('c', OrderedDict([('d', 'e')]))]) self.assertEqual(DICTJSON.fromJSON(str_json), json)
def cargaDictJSON(templatechain, requestcontext=None): # return DICTJSON.fromJSON("{" + cargaString(templatechain, requestcontext) + "}") return DICTJSON.fromJSON(cargaString(templatechain, requestcontext))