def __init__(self, data):
        self.HEADERS = Headers()
        self.HEADERS.show()
        self.data = data
        if self.data["metodo"] == None:
            d = redict({
                "[D|d]estacad[a|o]s?": [],
                "[P|p]opular(es)?": [],
                "[R|r]ecientes?": [],
                "[F|f]avorit[a|o]s?": [],
            })

            for elem in self.data["model"]["global"].obtenerFilas(
                    "Gestor-plugins"):

                if "Destacada" in elem[-1] or "Destacado" in elem[
                        -1] or "Destacados" in elem[
                            -1] or "Destacadas" in elem[-1]:

                    d["Destacada"].append(elem)
                if "Popular" in elem[-1]:
                    d["Popular"].append(elem)
                if "Reciente" in elem[-1]:
                    d["Reciente"].append(elem)
                if "Favorita" in elem[-1] or "Favoritas" in elem[
                        -1] or "Favoritos" in elem[-1]:
                    d["Favorita"].append(elem)

            print d
    def __init__(self, data):
        from modulos.ztec.zred import Headers
        self.HEADERS = Headers()

        self.model = {}
        self.data = data
        self.HEADERS.show()
        self.app_model = self.data["model"]
class plugins(object):
    def __init__(self, data):
        self.HEADERS = Headers()
        self.HEADERS.show()
        self.data = data
        if self.data["metodo"] == None:
            d = redict({
                "[D|d]estacad[a|o]s?": [],
                "[P|p]opular(es)?": [],
                "[R|r]ecientes?": [],
                "[F|f]avorit[a|o]s?": [],
            })

            for elem in self.data["model"]["global"].obtenerFilas(
                    "Gestor-plugins"):

                if "Destacada" in elem[-1] or "Destacado" in elem[
                        -1] or "Destacados" in elem[
                            -1] or "Destacadas" in elem[-1]:

                    d["Destacada"].append(elem)
                if "Popular" in elem[-1]:
                    d["Popular"].append(elem)
                if "Reciente" in elem[-1]:
                    d["Reciente"].append(elem)
                if "Favorita" in elem[-1] or "Favoritas" in elem[
                        -1] or "Favoritos" in elem[-1]:
                    d["Favorita"].append(elem)

            print d

    def install(self):
        import urllib2, urllib
        params = {
            "app": None,
            "control": self.data["control"],
            "action": "download",
            "item": self.data["item"]
        }
        params = urllib.urlencode(params)
        f = urllib2.urlopen(config.asenzor_host, params)

        ruta = f.read().strip()
        zred.download2(ruta, config.base_root + config.plugins_folder)
        f.close()

        zred.zipextract(config.base_root + config.plugins_folder +
                        ruta.split("/")[-1])
        os.remove(config.base_root + config.plugins_folder +
                  ruta.split("/")[-1])
        self.data["model"]["global"].instalarApp(self.data["item"])
Exemple #4
0
class static(object):
    """docstring for static"""
    def __init__(self, data):
        self.data = data
        self.HEADERS = Headers()
        self.HEADERS.set_headers({"Content-type": "text/plain\n"})
        if data["control"] != None and data["control"] in dir(self):
            exec("self." + data["control"] + "()")

    def plugin(self):
        for elem in rest["model"]["global"].obtenerFilas('Gestor-plugins'):

            if len(rest["args"]) > 1 and elem[0] == self.data["args"][
                    0] and self.data["args"][1] == "screen":

                print "Content-type: image/png" + "\n"
                print file(
                    config.base_root + config.projects_folder +
                    self.data["vista"] + "/screenshot.png", "rb").read()

    def screen(self):
        print "Content-type: image/png" + "\n"
        print file(
            config.base_root + config.projects_folder + self.data["app"] +
            "/screenshot.png", "rb").read()

    def script(self):
        if self.data["file"].endswith(".js"):
            self.HEADERS.show()
            if os.path.isfile(config.base_root + config.static_folder +
                              "js/python/__javascript__/" + self.data["file"]):

                f = open(
                    config.base_root + config.static_folder +
                    "js/python/__javascript__/" + self.data["file"], "r")
                script = convertir2(
                    f.read().replace("\\n",
                                     "\\\\n").replace("\\'", "\\\\'").replace(
                                         '\\"', '\\\\"'), ["<%", "%>"])
                doc = ""
                try:

                    exec(script)
                    print "var True=true;var False=false;var None=null;\n" + doc
                except Exception, e:
                    print e
                f.close()

        else:
Exemple #5
0
    def __init__(self, data):
        self.data = data
        self.HEADERS = Headers()
        self.HEADERS.set_headers({"Content-type": "text/plain\n"})
        self.HEADERS.show()
        apps = []
        if self.data["metodo"] == None:
            self.HEADERS.show()
            for elem in self.data["model"]["global"].obtenerFilas("apps"):
                if "Suspendida" in elem[4] and elem[0] == self.data["app"]:
                    self.data["app"] = None
                apps.append(elem[0])

            print {"apps": apps, "default_app": config.default_app}

        pass
class Plugin:
    """docstring for Plugin"""
    def __init__(self, data):
        from modulos.ztec.zred import Headers
        self.HEADERS = Headers()

        self.model = {}
        self.data = data
        self.HEADERS.show()
        self.app_model = self.data["model"]

    def cnt(self, data):
        """
		Este es el docstrings
		"""
        global config

    def metodo_desconocido(self):
        pass

    def action(self, data):
        global config
    def __init__(self):
        #====================================================================

        self.HEADERS = Headers()

        self.data = {"ajax": False}
        self.vista = "error404"

        self.data.update(getRest(config))

        import imp
        import cgi, cgitb
        cgitb.enable()

        data = cgi.FieldStorage()

        if (self.data["control"] == None
                and self.data['global_control'] == None
                and self.data['metodo'] == None and self.data['app'] == None
                and self.data['args'] == [] and self.data['request'] == {}
                and self.data['manager'] == False
                and self.data['ajax'] == False and self.data['kwargs'] == {}
                and self.data['action'] == None):
            self.data["app"] = config.default_app

        import os

        try:

            if type(data.value) == list:
                d = {}
                d2 = {}
                for elem in data.value:

                    if elem.name == "app":

                        if elem.value != "None" and elem.value != None:

                            self.data[elem.name] = normalizar(elem.value)

                            self.data["request"][elem.name] = elem

                    else:
                        if elem.name in d:
                            d[elem.name].append(elem.value)
                            d2[elem.name].append(elem)
                            self.data[elem.name] = d[elem.name]
                            self.data["request"][elem.name] = d2[elem.name]
                        else:
                            d[elem.name] = [elem.value]
                            d2[elem.name] = [elem]
                            self.data[elem.name] = normalizar(elem.value)
                            self.data["request"][elem.name] = elem

            else:
                """
		        params=data.value.split("/")[-1].split("&")


		        for elem in params:
		            k,v=elem.split("=")
		            self.data[k]=normalizar(v)                                                     
		            self.data["request"][k]={"value":normalizar(v)}                                                     
		        """

        except Exception, e:
            if "action" not in data:
                self.data["action"] = None
            else:
                self.data["action"] = data["action"].value
                self.data["request"]["action"] = data["action"]
Exemple #8
0
 def action(data,p):#manejador de los formularios
  
  sys.path.append(p["base_root"]+"../admin/")


  



  
  debug=False
  contenttype=False



  from config import config



  import settings.routes as routes
  
  import settings.config as settings
  import imp
  from modulos.ztec.zu import redict






  
  sys.path.append(p["base_root"]+"../admin/"+routes.libs_folder)
  sys.path.append(p["base_root"]+"../admin/"+routes.models_folder)

  
  
  
  errores=[]
  for elem in settings.libs_python:
   exec("import "+elem,locals())
  
  import modulos.ztec.zu as zu
  import ztec.zred as zred 


  

  

  
  from modulos.ztec.zred import clienteSock,getCookie,setCookie, redirecter,decode,normalizar,encode,Headers
  HEADERS=Headers()
  if p["method"]=="ajax":
    HEADERS.set_headers({"Content-type":"text/plain"})
  #==============================================================================
  #INICIALIZACION DE LOS MODELOS
  if "model" not in p:
    p["model"]={}
  if "opciones" not in p:
    p["opciones"]={}


  contenido=p["model"]["global"].obtenerContenido(p["app"],"apps")[p["app"]]  

  p["model"]["global"].p=p
  p["model"]["usuarios"].p=p
  for k,db in enumerate(contenido[1]):
    if contenido[1][db]["value"] in settings.dbs:

      exec("from "+contenido[1][db]["value"]+"_model import model as model"+str(k),locals())    
      if "token" not in p:
       
       exec('p["model"][contenido[1][db]["value"]]=model'+str(k)+'(p["base_root"]+"../admin/"+routes.models_folder+contenido[1][db]["value"],p["base_root"]+"../admin/"+routes.request_folder,"user",debug=debug,ext=".py")',locals())
       p["model"][contenido[1][db]["value"]].models["global"]=p["model"]["global"]

       p["model"]["global"].models[contenido[1][db]["value"]]=p["model"][contenido[1][db]["value"]]
       if "Opciones" in p["model"][contenido[1][db]["value"]].db.tablas:
            p["opciones"][contenido[1][db]["value"]]=p["model"][contenido[1][db]["value"]].obtenerFilas("Opciones")
       

      else:

       exec('p["model"][contenido[1][db]["value"]]=model'+str(k)+'(p["base_root"]+"../admin/"+routes.models_folder+contenido[1][db]["value"],p["base_root"]+"../admin/"+routes.request_folder,p["token"],debug=debug,ext=".py")',locals())
       p["model"][contenido[1][db]["value"]].models["global"]=p["model"]["global"]
       p["model"]["global"].models[contenido[1][db]["value"]]=p["model"][contenido[1][db]["value"]]

       if "Opciones" in p["model"][contenido[1][db]["value"]].db.tablas:
            p["opciones"][contenido[1][db]["value"]]=p["model"][contenido[1][db]["value"]].obtenerFilas("Opciones") 
    p["model"][contenido[1][db]["value"]].p=p



    
  
  #===================================================================================
  #MANEJO DE REGISTRO DE ACCIONES DE USARIO(SESION)
  

  cookies=getCookie()
  p["cookies"]=cookies
  token2=None
  tokens={}



  

  if "token" in cookies:

   tokens=normalizar(cookies["token"])
  if "token2" in cookies:
    token2=normalizar(cookies["token2"])
   


   

  if settings.app in tokens and token2==None:

    p["token"]=tokens[settings.app]
    if p["model"]["usuarios"].isUser(token=tokens[settings.app]) and p["model"]["usuarios"].consultarLogin(tokens[settings.app]):
      p["user"]=p["model"]["usuarios"].obtenerUsuario(p["token"])
      p["login"]=True
      p["isGlobalUser"]=False
    else:
      p["login"]=False
    
  elif token2!=None and p["model"]["global"].consultarLogin(token2):
    p["token"]=token2
    p["user"]=p["model"]["global"].obtenerUsuario(p["token"])
    p["login"]=True
    p["isGlobalUser"]=True
  else:
    p["login"]=False
  
  for elem in p["model"]:
   if "token" in p:
    p["model"][elem].token=p["token"]
   else:
    p["model"][elem].token="user"
  #=================================================================================
  #CREAR LOS LANZADORES DEL LOS PLUGINS
  p["plugins"]={}
  for k,plugin in enumerate(p["model"]["main"].obtenerFilas("Plugins")):
    if plugin[1]==True:
      p["plugins"][plugin[0]]=imp.load_source("plugin"+str(k),config.base_root+config.plugins_folder+plugin[0]+"/"+"default.py").Plugin(p["model"])
      p["plugins"][plugin[0]].action(data,p)


      


  #========================================================================================

  if p["cookies"]!={} and normalizar(p["cookies"]["beforeArgs"])!=[]:
    if len(normalizar(p["cookies"]["beforeArgs"]))>0:
      beforeAction=normalizar(p["cookies"]["beforeArgs"])[0]
      if len(normalizar(p["cookies"]["beforeArgs"]))>1:
          indice=normalizar(p["cookies"]["beforeArgs"])[1]
  else:
   try:
     beforeAction=data["action"].value
   except Exception as e:
     beforeAction=""
   indice=None

  #=========================================================================
  #CARGA DE SUBCONTROLADORES 
  
  for elem in settings.global_post_controllers:
   try:


    sub=open("../"+config.controller_folder+config.global_folder+routes.http_folder+elem+".py","r")
    script=sub.read()
    sub.close()
    exec(script,locals())

   except Exception as e:
    print "#error: ",elem," ",e
    errores.append([sys.exc_info(),[p["base_root"]+routes.controller_folder+"default.py",p["base_root"]+routes.controller_folder+routes.http_folder+elem+".py"]])

  for elem in settings.post_controllers:
    
    sub=open(config.base_root+config.apps_folder+p["app"]+"/user/"+config.controles_dir+"/"+routes.http_folder+elem+".py","r")
    script=sub.read()
    try:
     exec(script,locals()) 
    except Exception as e:
     if settings.mod_debug!=False:
      import traceback

      exc_type,exc_obj,exc_tb=sys.exc_info()
      fname = exc_tb.tb_frame.f_code.co_filename
      print "#==================================="
      print "#No se pudo cargar el modulo ",elem
      print "# ","".join(traceback.format_exception(exc_type,fname,exc_tb))
      print "#", e
      print "#==================================="

  for elem in settings.post_custom_controllers:
    sub=open(config.base_root+config.apps_folder+p["app"]+"/user/"+config.controles_dir+"/"+routes.custom_http_folder+elem+".py","r")
    script=sub.read()
    sub.close()
    try:
     exec(script,locals()) 
    except Exception as e:
     if settings.mod_debug!=False:
      import traceback
      exc_type,exc_obj,exc_tb=sys.exc_info()
      fname = exc_tb.tb_frame.f_code.co_filename
      print "#==================================="
      print "#No se pudo cargar el modulo ",elem
      print "# ","".join(traceback.format_exception(exc_type,fname,exc_tb))
      print "#", e
      print "#==================================="
Exemple #9
0
 def cnt(p,m):#Manejador de las paginas
  p["method"]="get"

  debug=False
  import sys
  

  import config
  import settings.config as settings
  import settings.routes as routes


  import modulos.ztec.zu as zu
  from modulos.ztec.zu import redict
  import ztec.zred as zred 
  from modulos.ztec.zred import zform 
  from modulos.ztec.zt import ZT
  import imp
  
  #print config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"traducciones-"+settings.lang.upper()
  
  routes.base_url=config.base_url+(settings.app+"/") if config.default_app!=settings.app else ""


  from modulos.ztec.zred import clienteSock,getCookie,setCookie, redirecter,normalizar,decode,Headers
  HEADERS=Headers()

  """
  for elem in settings.libs_python:
   exec("import "+elem,locals())
   pass
  """
  p["AsenZor:Detalles"]={"Versi贸n":0.1,"Autor original":"Jes煤s Abraham Zerpa Maldonado",
          "Email":"*****@*****.**","Website":"https://zerpatechnology.com.ve",
          "Actualizaciones":"AsenZor esta en su versi贸n mas reciente"}
  p["AsenZor:chat-box"]={"comentarios":1}

  p["defaultpath"]="../"+config.apps_folder+p["app"]+"/user/"

  #============================================================
  #Cuerpo del controlador
  #------------------------------------------------------------
  #Secci贸n de parametrisaje


  data=p
  data["login"]=False
  beforeAction=""
  contenido=p["model"]["global"].obtenerContenido(p["app"],"apps")[p["app"]]  
  embebe_request=[]
  errores=[]


  data["model"]["global"].p=p
  data["model"]["usuarios"].p=p

  
  try:
   for k,db in enumerate(contenido[1]):
    if contenido[1][db]["value"] in settings.dbs:
      exec("from modelos."+contenido[1][db]["value"]+"_model import model as model"+str(k),locals())    
      pass
      if "token" not in p:
       exec('data["model"][contenido[1][db]["value"]]=model'+str(k)+'(p["base_root"]+"../admin/"+routes.models_folder+contenido[1][db]["value"],p["base_root"]+"../admin/"+routes.request_folder,"user",debug=debug,ext=".py")',locals())
       data["model"][contenido[1][db]["value"]].models["global"]=data["model"]["global"]


       data["model"]["global"].models[contenido[1][db]["value"]]=data["model"][contenido[1][db]["value"]]
       
       if "Opciones" in data["model"][contenido[1][db]["value"]].db.tablas:
            
            data["opciones"][contenido[1][db]["value"]]=data["model"][contenido[1][db]["value"]].obtenerFilas("Opciones")
      else:
       exec('data["model"][contenido[1][db]["value"]]=model'+str(k)+'(p["base_root"]+"../admin/"+routes.models_folder+contenido[1][db]["value"],p["base_root"]+"../admin/"+routes.request_folder,p["token"],debug=debug,ext=".py")',locals())
       data["model"][contenido[1][db]["value"]].models["global"]=data["model"]["global"]


       data["model"]["global"].models[contenido[1][db]["value"]]=data["model"][contenido[1][db]["value"]]
       if "Opciones" in data["model"][contenido[1][db]["value"]].db.tablas:
            data["opciones"][contenido[1][db]["value"]]=data["model"][contenido[1][db]["value"]].obtenerFilas("Opciones")
       
  except Exception as e:

   if settings.mod_debug!=False:
    import traceback
    try:
      exc_type,exc_obj,exc_tb=sys.exc_info()
      fname = exc_tb.tb_frame.f_code.co_filename
      print "#===================================<br>"
      print "#No se pudo crear la base de datos"
      print "# ","".join(traceback.format_exception(exc_type,fname,exc_tb)).replace("%5Cn","<br>")+"<br>"
      print "#", e,"<br>"
      print "#==================================="
      raise

    except:
      pass
  
  
  

  cookies=getCookie()




  token2=None
  tokens={}





  

  if "token" in cookies:


   tokens=normalizar(cookies["token"])
  if "token2" in cookies:
    token2=normalizar(cookies["token2"])
   


   

  
  if settings.app in tokens and token2==None:
    
    p["token"]=tokens[settings.app]
    if p["model"]["usuarios"].isUser(token=tokens[settings.app]) and p["model"]["usuarios"].consultarLogin(tokens[settings.app]):
      p["user"]=p["model"]["usuarios"].getUser(p["token"])
      p["login"]=True
      p["isGlobalUser"]=False
    else:
      p["login"]=False
    
  elif token2!=None and p["model"]["global"].consultarLogin(token2):
    p["token"]=token2
    p["user"]=p["model"]["global"].getUser(p["token"])
    p["login"]=True
    p["isGlobalUser"]=True
  else:
    p["login"]=False
  
  for elem in data["model"]:
   if "token" in p:
    data["model"][elem].token=p["token"]
   else:
    data["model"][elem].token="user"
  data["cookies"]=cookies
  
  if p["login"]==True:
    
    miscookies=getCookie()
    import Cookie
    cookie=Cookie.SimpleCookie()  
    folder=os.getcwd().split("/")[-2]
    if "notification" not in miscookies:

          cookie["notification"]="False"
          cookie["notification"]["path"]="/"+(folder if folder!=config.host_folder else "")
          import time
          tiempo=time.gmtime()
          meses=[ "Jan",
            "Feb",
            "Mar",
            "Apr",
            "May",
            "Jun",
            "Jul",
            "Aug",
            "Sep",
            "OcT",
            "Nov",
            "Dec"]
          dias=["Mon",
            "Tue",
            "Wed",
            "Thu",
            "Fri",
            "Sat",
            "Sun"]
          
          cookie["notification"]["expires"]= str(dias[tiempo.tm_wday+1 if len(dias)<tiempo.tm_wday+1 else 0])+", "+str(tiempo.tm_mday+1)+" "+str(meses[tiempo.tm_mon])+"  "+str(tiempo.tm_hour)+":"+str(tiempo.tm_min)+":"+str(tiempo.tm_sec)+" UTC"     

          print cookie
  
  zt=ZT(config.base_root+(config.apps_folder if data["manager"]==False else config.projects_folder)+settings.app+"/admin/"+routes.models_folder+routes.traducciones_folder+"traducciones-"+settings.lang.upper(),"request/",p["token"] if "token" in p else "",ext=".py")  



  import urllib,urllib2
  temp_p={}
  for elem in p:
    if type(elem)==int:
      temp_p[elem]=p[elem]
    elif type(elem)==str:
      temp_p[elem]=p[elem]
    elif type(elem)==bool:
      temp_p[elem]=p[elem]
    elif type(elem)==float:
      temp_p[elem]=p[elem]
    elif type(elem)==dict:
      temp_p[elem]=p[elem]
    elif type(elem)==list:
      temp_p[elem]=p[elem]
    elif type(elem)==tuple:
      temp_p[elem]=p[elem]
  
  php_request={}

  #=================================================================================
  #CREAR LOS LANZADORES DEL LOS PLUGINS
  
  data["plugins"]={}
  data["plugins-hooks"]=[]
  for k,plugin in enumerate(data["model"]["main"].obtenerFilas("Plugins")):
    if plugin[1]==True:
      data["plugins"][plugin[0]]=imp.load_source("plugin"+str(k),config.base_root+config.plugins_folder+plugin[0]+"/"+"default.py").Plugin(p["model"])
      hook=data["model"]["global"].obtenerFilas("Plugins")[k][1][1]
      
      
      data["plugins"][plugin[0]].cnt(data)

      for accion in hook:
        data["plugins-hooks"].append([accion["name"].split("-")[1],accion["value"]])
      
      
  #========================================================================================

  def servir(vista,data=data,path1=None,path2=None,p=p,m=m,settings=settings,config=config,routes=routes,isglobal=None,plugins=data["plugins"]):    

    import __builtin__
    import os
    from modulos.ztec.zred import clienteSock,getCookie,setCookie, redirecter,normalizar,encode
    str=__builtin__.str

     
    data["isglobal"]=isglobal

    if p["control"]=="admin":
      if path1==__builtin__.None:
        
          path1=p["base_root"]+"../admin/"+routes.vistas_folder

      if path2==__builtin__.None:
        
          path2=p["base_root"]+"../admin/"+routes.templates_url


      

      #data["incluir"]=m["incluir"]

      m["servir"](vista,path1,path2,data=data,isglobal=isglobal,plugins=plugins)


    else:

     if vista in settings.vistas:
      if path1==__builtin__.None:
          path1=p["base_root"]+routes.vistas_folder
      if path2==__builtin__.None:
          path2=p["base_root"]+routes.templates_url
      
      #data["incluir"]=m["incluir"]

      m["servir"](vista,path1,path2,data=data,isglobal=isglobal,plugins=plugins)


  for elem in settings.get_php_controllers:
    try:

      params = urllib.urlencode({"p":temp_p})
      f=urllib2.urlopen(config.base_url+config.apps_folder+settings.app+"/user/"+routes.controller_folder+routes.http_folder+routes.php_folder+elem+".php",params)
      php_request[elem]=f.read()
      f.close()


    except Exception,e:
      print e
      errores.append([sys.exc_info(),[p["base_root"]+routes.controller_folder+"default.py",config.base_url+config.apps_folder+settings.app+"/user/"+routes.controller_folder+"http/"+elem+".php"]])
Exemple #10
0
class apps(object):
    """docstring for apps"""
    def __init__(self, data):
        self.data = data
        self.HEADERS = Headers()
        self.HEADERS.set_headers({"Content-type": "text/plain\n"})
        self.HEADERS.show()
        apps = []
        if self.data["metodo"] == None:
            self.HEADERS.show()
            for elem in self.data["model"]["global"].obtenerFilas("apps"):
                if "Suspendida" in elem[4] and elem[0] == self.data["app"]:
                    self.data["app"] = None
                apps.append(elem[0])

            print {"apps": apps, "default_app": config.default_app}

        pass

    def versiones_disponibles(self):
        versiones = {}

        self.HEADERS.show()
        if len(self.data["args"]) > 2:
            if self.data["args"][2] == "sizes":
                for elem in config.versiones_disponibles:
                    for elem2 in self.data["model"]["global"].obtenerFilas(
                            "Asenzor"):
                        if elem2[1][0]["value"] == elem:
                            versiones[elem2[1][4]
                                      ["value"]] = elem2[1][5]["value"]
                print versiones

        else:

            for elem in config.versiones_disponibles:
                for elem2 in self.data["model"]["global"].obtenerFilas(
                        "Asenzor"):
                    if elem2[1][0]["value"] == elem:
                        versiones[elem] = elem2[1][4]["value"]
            print versiones

    def webapp(self):
        self.HEADERS.show()
        if self.data["action"] == "install":
            import urllib2, urllib

            params = {
                "app": "asenzor",
                "control": self.data["control"],
                "action": "download",
                "item": self.data["item"]
            }

            params = urllib.urlencode(params)

            f = urllib2.urlopen(
                config.asenzor_host + config.controller_folder + "ajax.py",
                params)

            ruta = f.read().strip()
            zred.download2(ruta, config.base_root + config.apps_folder)
            f.close()

            zred.zipextract(config.base_root + config.apps_folder +
                            ruta.split("/")[-1])
            os.remove(config.base_root + config.apps_folder +
                      ruta.split("/")[-1])
            self.data["model"]["global"].instalarApp(self.data["item"])

    def download(self):
        zred.downloader(config,
                        config.base_root + config.projects_folder +
                        self.data["item"] + ".zip",
                        get=False)
        pass

    def unistall(self):
        pass

    def install(self):
        pass

    def allapps(self):

        self.HEADERS.show()
        d = redict({
            "[D|d]estacad[a|o]s?": [],
            "[P|p]opular(es)?": [],
            "[R|r]ecientes?": [],
            "[F|f]avorit[a|o]s?": [],
        })

        for elem in self.data["model"]["global"].obtenerFilas("Gestor-apps"):

            if "Destacada" in elem[-1] or "Destacado" in elem[
                    -1] or "Destacados" in elem[-1] or "Destacadas" in elem[-1]:

                d["Destacada"].append(elem)
            if "Popular" in elem[-1]:
                d["Popular"].append(elem)
            if "Reciente" in elem[-1]:
                d["Reciente"].append(elem)
            if "Favorita" in elem[-1] or "Favoritas" in elem[
                    -1] or "Favoritos" in elem[-1]:
                d["Favorita"].append(elem)

        print d
Exemple #11
0
class Controlador(object):
	"""docstring for Vistas"""
	def __init__(self,data):      
	  
	  self.data=data
	  

	  self.request=data["request"] 
	  self.isglobal=False
	  self.admin=False

	  self.servida=False
	  self.plugins=data["plugins"]

	  self.vista=None

	  self.tabla="Paginas"
	  self.embebed=None

	  self.model_name="paginas"
	  self.vistas=[]
	  self.ruta_html=""
	  self.ruta_python=""
	  self.HEADERS=Headers()
	  
	  

	  

	  self.zt=None
	  if self.data["app"]!=None:

	  	import settings.config as settings
	  	
	  	
	  	import settings.routes as routes


	  	self.ruta_widget=config.base_root+config.apps_folder+settings.app+"/user/"+routes.vistas_folder
	  	self.ruta_python=self.ruta_html+routes.templates_folder
	  	from ztec.zt import ZT
	  	self.zt=ZT(config.base_root+(config.apps_folder if data["manager"]==False else config.projects_folder)+settings.app+"/admin/"+routes.models_folder+routes.traducciones_folder+"traducciones-"+settings.lang.upper(),"request/",data["token"] if "token" in data else "user",ext=".py")
	  self.data_temp={}


	  


	  for elem in data:
	    if type(elem)==int:
	      self.data_temp[elem]=data[elem]
	    elif type(elem)==str:
	      self.data_temp[elem]=data[elem]
	    elif type(elem)==bool:
	      self.data_temp[elem]=data[elem]
	    elif type(elem)==float:
	      self.data_temp[elem]=data[elem]
	    elif type(elem)==dict:
	      self.data_temp[elem]=data[elem]
	    elif type(elem)==list:
	      self.data_temp[elem]=data[elem]
	    elif type(elem)==tuple:
	      self.data_temp[elem]=data[elem]


	def add_vista(self,vista):
		if vista not in self.vistas:
			self.vistas.append(vista)
			self.vista=vista
	def hacer_constructor(self,ul_class="navbar-nav mr-auto",li_class="nav-item",a_class="nav-link",a_atts="",li_atts="",ul_atts="",funcion=None,constructor=None,marcadores=None):

		def construir_menu(menu,ul_class=ul_class,li_class=li_class,a_class=a_class, a_atts=a_atts,li_atts=li_atts,ul_atts=ul_atts, funcion=funcion,constructor=constructor,marcadores=marcadores):
			if constructor==None:
				constructor=self.construir_menu

			html="<ul class='"+ul_class+"' "+ul_atts+">"
			
			for k,tag in enumerate(menu):
				if type(tag["url"])==list:
					#if marcadores!=None and k in list(marcadores):

					html+=(("<li "+li_atts+" class='"+li_class+"'><a tabindex='-1'  class='"+a_class+"' "+a_atts+" href='"+config.base_url+tag["url"][3]+"/"+tag["url"][4]+"'>"+tag["name"]+constructor(tag["children"])+"</a></li>") if funcion==None else funcion(tag,constructor))
				elif type(tag["url"])==str:
					
					html+=("<li "+li_atts+" class='"+li_class+"'><a tabindex='-1'  class='"+a_class+"' "+a_atts+" href='"+tag["url"]+"'>"+tag["name"]+constructor(tag["children"])+"</a></li>") if funcion==None else funcion(tag,constructor)
					pass

			html+="</ul>"
			return html
		return construir_menu

	def construir_menu(self,menu,ul_class="nav navbar-nav",li_class="nav-item",a_class="nav-link",a_atts="",li_atts="",ul_atts="",funcion=None,constructor=None):

		if constructor==None:
			constructor=self.construir_menu


		
		html="<ul class='"+ul_class+"'>"
		
		for tag in menu:
			

			if type(tag["url"])==list:

				html+="<li class='"+li_class+"' "+li_atts+"  >"+("<a tabindex='-1'  class='"+a_class+"' "+a_atts+"  href='"+config.base_url+tag["url"][3]+"/"+tag["url"][4]+"'>"+tag["name"]+"</a>"+constructor(tag["children"])+"</li>"  if funcion==None else funcion(tag,constructor) )
			else:
				
				html+=("<li class='"+li_class+"' "+li_atts+" >"+("<a  tabindex='-1' class='"+a_class+"' "+a_atts+"  href='"+tag["url"]+"'>"+tag["name"]+"</a>"+constructor(tag["children"])+"</li>")) if funcion==None else funcion(tag,constructor)
				pass

		html+="</ul>"
		return html

	def main_menu(self,ul_class="navbar-nav mr-auto",li_class="nav-item",a_class="nav-link",funcion=None,constructor=None):
		
		return self.construir_menu(self.data["model"]["menus"].obtenerMenu("main")[1][0],ul_class=ul_class,li_class=li_class,a_class=a_class,funcion=funcion,constructor=constructor)

	def foot_menu(self,_class="",_id="foot_menu"):

		return self.construir_menu(self.data["model"]["menus"].obtenerMenu("footer")[1][0],_class)

	def top_bar_menu(self,_class="",_id="top_bar_menu"):

		return self.construir_menu(self.data["model"]["menus"].obtenerMenu("top")[1][0],_class)
		
	def my_acount_menu(self,_class="",_id="main_menu"):

		return self.construir_menu(self.data["model"]["menus"].obtenerMenu("my_acount")[1][0],_class)

	def metodo_desconocido(self):
		
		from modulos.ztec.zred import gringolizar
		if self.data["app"]!=None:
		  	import settings.config as settings
		  	import settings.routes as routes
		
		#self.vista="error404"
		
		
		for elem in self.data["model"][self.model_name].obtenerFilas(self.tabla):

			if self.data["metodo"]==None:
				
				if gringolizar(elem[0],"-")==self.data["control"]:
					metadatos=self.data["model"][self.model_name].formatearMetadatos(elem[4])
					self.data["post"]=elem[1]
					self.vista=metadatos["layout"]
			else:

				if gringolizar(elem[0],"-")==self.data["metodo"]:

					metadatos=self.data["model"][self.model_name].formatearMetadatos(elem[4])
					self.data["post"]=elem[1]

					self.vista=metadatos["layout"]

		self.servir()



	def generar(self,ruta_html,ruta_python,cabeceras):

	  generar2(ruta_html,ruta_python,cabeceras) 

	def incluir(self,data,widgets,isglobal=False,admin=False,embebido=False):

	  widget=""
	  import urllib,urllib2 
	  from modulos.ztec.zu import filtrar_datos_planos
	  from modulos.ztec.zu import rstr
	  incluir=self.incluir

	  do_shortcode=self.do_shortcode
	  main_menu=self.main_menu
	  foot_menu=self.foot_menu
	  top_bar_menu=self.top_bar_menu
	  my_acount=self.my_acount_menu
	  hacer_constructor=self.hacer_constructor

	  import imp
	  if self.data["global_control"]!=None:
	  	plugin=imp.load_source("",config.base_root+config.plugins_folder+self.data["control"]+"/plugin.py")
	  if self.data["app"]!=None:
	  	import settings.config as settings
	  	import settings.routes as routes
	  	routes.base_url=config.base_url+settings.app+"/"
	  	


	  def wapper(target,constructor):
	  	global len
	  	global False
	  	global True
	  	if len(target["children"])>0:
	  		sub=False
	  		for elem in target["children"]:
	  			if len(elem["children"])>0:
	  				sub=True
	  				break

	  		return '<li class="'+("dropdown" if sub==False else "dropdown-submenu")+'"><a tabindex="-1"  class="dropdown-toggle nav-link" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true"><b>'+target["name"]+'</b> <span class="caret"></span>'+constructor(target["children"])+'</li>'
	  	else:
	  		return "<li><a class='nav-link'   tabindex='-1'  href='"+target["url"]+"'>"+target["name"]+"</a>""</li>"
	  
	  if type(widgets)==list or type(widgets)==tuple:
	    if embebido=="php":
	      for w in widgets:
	        pass
	    elif embebido=="rb":
	      for w in widgets:
	        generar2(self.ruta_widget+(routes.widgets_folder if self.data["app"]!=None else "")+w+".html.erb",self.ruta_widget+w+".rb","")
	    else:

	      for w in widgets:
	      	if len(w)==1:
	      		self.generar(self.ruta_widget+(routes.widgets_folder if self.data["app"]!=None else "")+w+".html",self.ruta_widget+w+".py","")
		        f=open(self.ruta_widget+(routes.widgets_folder if self.data["app"]!=None else "")+w+".py","r")
		        widget+=f.read()+"\n"
		        f.close()
	      	elif len(w)==2:
		      	for w2 in w[1]:
		      		if w[0]==data["action"]:


				        self.generar((self.ruta_widget if self.isglobal==False else config.base_root+config.vistas_folder)+(routes.widgets_folder if self.data["app"]!=None else "")+w2+".html",(self.ruta_widget if self.isglobal==False else config.base_root+config.vistas_folder)+(routes.widgets_folder if self.data["app"]!=None else "")+w2+".py","")
				        f=open((self.ruta_widget if self.isglobal==False else config.base_root+config.vistas_folder)+(routes.widgets_folder if self.data["app"]!=None else "")+w2+".py","r")
				        widget+=f.read()+"\n"
				        f.close()
	      doc=""


	      exec(widget)
	      return doc
	  elif type(widgets)==str:

	    if embebido=="php":
	      params = urllib.urlencode({"data":filtrar_datos_planos(self.data)})
	      
	      f=urllib2.urlopen(config.base_url+rstr(self.ruta_widget.replace("/admin/","/user/"),"/",5)+widgets+".php",params)
	      return f.read()
	    elif embebido=="rb":
	      self.generar(self.ruta_widget+(routes.widgets_folder if self.data["app"]!=None else "")+widgets+".html.rb",self.ruta_widget+widgets+".rb","")
	      params = urllib.urlencode({"data":filtrar_datos_planos(self.data)})
	      f=urllib2.urlopen(config.base_url+rstr(self.ruta_widget.replace("/admin/","/user/"),"/",5)+widgets+".rb",params)
	      return f.read()
	    else:
	    	self.HEADERS.show()
	    	
	    	
	    	if isglobal:

	    		routes.widget_root=config.base_root+config.vistas_folder+config.widgets_folder
	    		routes.widget_base_url=config.base_url+routes.widget_root[len(config.base_root):]


	    	elif data["control"]=="admin":
	    		routes.widget_root=self.ruta_widget.replace("/user/","/admin/")
	    		routes.widget_base_url=config.base_url.replace("/user/","/admin/")+routes.widget_root[len(config.base_root):]
	    	else:
	    		routes.widget_root=self.ruta_widget
	    		routes.widget_base_url=config.base_url+routes.widget_root[len(config.base_root):]
	    	
	    	
	    	if os.path.exists(routes.widget_root+widgets+".html"):
		    	self.generar(routes.widget_root+widgets+".html",routes.widget_root+widgets+".py","")
		    	
		    	f=open(routes.widget_root+widgets+".py","r")


		    	widget+=f.read()+"\n"


		    	f.close()
		    	doc=""

		    	try:

		    		exec(widget)
		    	except Exception as e:
		    		return e
		    	
		    	return doc	    		
	    	elif os.path.exists(routes.widget_root+widgets+"/"+widgets+".html"):

	    		routes.widget_root+=widgets+"/"
	    		routes.widget_base_url+=widgets+"/"
	    		

		    	self.generar(routes.widget_root+widgets+".html",routes.widget_root+widgets+".py","")
		    	f=open(routes.widget_root+widgets+".py","r")


		    	widget+=f.read()+"\n"

		    	f.close()
		    	doc=""


		    	try:
		    		exec(widget)
		    	except Exception as e:
		    		return e
		    	

		    	return doc


	def do_shortcode(self,string):
	
		try:

		  import imp
		  

		  __plugins__={}
		  __etiquetas__=[]
		  __etiquetas2__=[]

		  for plugin in self.plugins:

		    for short in self.plugins[plugin].shortcodes:
		      
		      __etiquetas__.append(["["+self.plugins[plugin].plugin.name+"-"+short,"]"])


		      if self.plugins[plugin].shortcodes[short].contenedor==True:
		        __etiquetas2__.append("[/"+self.plugins[plugin].plugin.name+"-"+short+"]")
		      else:
		        __etiquetas2__.append(None)
		      

		      
		      __plugins__[self.plugins[plugin].plugin.name+"-"+short]=self.plugins[plugin].shortcodes[short].run

		  return convertir3(string,__etiquetas__,__etiquetas2__,__plugins__)        
		  
		except Exception,e:
		  print "#",e
		
		pass
Exemple #12
0
	def __init__(self,plugin,data):
		
		import imp
		Controlador.__init__(self,data)

		self.login=Login(data)
		
		
		import os

		from modulos.ztec.zred import  Headers,gringolizar
		self.app=None
		self.model={}
		self.shortcodes={}
	
		import sys


		self.plugin=plugin

		self.HEADERS=Headers()
		l=self.plugin.navegacion
		if self.data["model"]["main"].update():

			for elem in self.data["model"]["main"].obtenerFilas("AdminMenu"):
						if elem in l:
							l.remove(elem)
		
		for elem2 in l:                
				self.data["model"]["main"].db("AdminMenu").insertar(elem2[0],elem2[1],elem2[2],elem2[3])


		self.HEADERS.set_headers({"Content-type":"text/plain\n"})
		from modulos.ztec.intervalor.control import generar2		
		for w in plugin.widgets:
			if os.path.exists(config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+".html"):
				 	generar2(config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+".html",config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+".py","#!/usr/bin/python\n# -*- coding: utf-8 -*-\n")
			elif os.path.exists(config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+"/"+w+".html"):
						generar2(config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+"/"+w+".html",config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+"/"+w+".py","#!/usr/bin/python\n# -*- coding: utf-8 -*-\n")


		if self.data["app"]!=None:

			import app
			from app import app
			self.app=app()
			from settings import config as settings
			from settings import routes

			
			for elem in plugin.modelos:

				if os.path.exists(config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/"+elem+"_struct.py"):				
					if os.path.exists(config.base_root+config.plugins_folder+plugin.name+"/modelos/"+elem+"_model.py"):
						self.model[elem]=imp.load_source(elem+"_model",config.base_root+config.plugins_folder+plugin.name+"/modelos/"+elem+"_model.py").model(
							config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/"+elem,
							config.base_root+config.modelos_folder+"request/","user",ext=".py"
							)
					else:
						print "El modelo: "+elem+" del plugin: "+plugin.name+" no fue encontrado"
					

				else:
					if not os.path.exists(config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/"):
						os.mkdir(config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/")
					if os.path.exists(config.base_root+config.plugins_folder+plugin.name+"/modelos/"+elem+"_struct.py"):
						f=open(config.base_root+config.plugins_folder+plugin.name+"/modelos/"+elem+"_struct.py","r")
						struct=f.read()
						f.close()
						f=open(config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/"+elem+"_struct.py","w")
						f.write(struct)
						f.close()				

						self.model[elem]=imp.load_source(elem+"_model",config.base_root+config.plugins_folder+plugin.name+"/modelos/"+elem+"_model.py").model(

						config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/"+elem,
							config.base_root+config.modelos_folder+"request/","user",ext=".py"
							)
						



		for elem in plugin.shortcodes:
					
					self.shortcodes[elem]=imp.load_source(elem+"_model",config.base_root+config.plugins_folder+self.plugin.name+"/shortcodes/"+elem+".py").shortcode(self)
					
					self.shortcodes[elem].ruta=self.plugin.__path__+"/widgets/"

					self.shortcodes[elem].url=config.base_url+config.plugins_folder+"/".join(self.plugin.__path__.split("/")[-2:])+"/widgets/"
Exemple #13
0
class Plugin(Controlador):
	"""docstring for Plugin"""
	def __init__(self,plugin,data):
		
		import imp
		Controlador.__init__(self,data)

		self.login=Login(data)
		
		
		import os

		from modulos.ztec.zred import  Headers,gringolizar
		self.app=None
		self.model={}
		self.shortcodes={}
	
		import sys


		self.plugin=plugin

		self.HEADERS=Headers()
		l=self.plugin.navegacion
		if self.data["model"]["main"].update():

			for elem in self.data["model"]["main"].obtenerFilas("AdminMenu"):
						if elem in l:
							l.remove(elem)
		
		for elem2 in l:                
				self.data["model"]["main"].db("AdminMenu").insertar(elem2[0],elem2[1],elem2[2],elem2[3])


		self.HEADERS.set_headers({"Content-type":"text/plain\n"})
		from modulos.ztec.intervalor.control import generar2		
		for w in plugin.widgets:
			if os.path.exists(config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+".html"):
				 	generar2(config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+".html",config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+".py","#!/usr/bin/python\n# -*- coding: utf-8 -*-\n")
			elif os.path.exists(config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+"/"+w+".html"):
						generar2(config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+"/"+w+".html",config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+"/"+w+".py","#!/usr/bin/python\n# -*- coding: utf-8 -*-\n")


		if self.data["app"]!=None:

			import app
			from app import app
			self.app=app()
			from settings import config as settings
			from settings import routes

			
			for elem in plugin.modelos:

				if os.path.exists(config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/"+elem+"_struct.py"):				
					if os.path.exists(config.base_root+config.plugins_folder+plugin.name+"/modelos/"+elem+"_model.py"):
						self.model[elem]=imp.load_source(elem+"_model",config.base_root+config.plugins_folder+plugin.name+"/modelos/"+elem+"_model.py").model(
							config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/"+elem,
							config.base_root+config.modelos_folder+"request/","user",ext=".py"
							)
					else:
						print "El modelo: "+elem+" del plugin: "+plugin.name+" no fue encontrado"
					

				else:
					if not os.path.exists(config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/"):
						os.mkdir(config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/")
					if os.path.exists(config.base_root+config.plugins_folder+plugin.name+"/modelos/"+elem+"_struct.py"):
						f=open(config.base_root+config.plugins_folder+plugin.name+"/modelos/"+elem+"_struct.py","r")
						struct=f.read()
						f.close()
						f=open(config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/"+elem+"_struct.py","w")
						f.write(struct)
						f.close()				

						self.model[elem]=imp.load_source(elem+"_model",config.base_root+config.plugins_folder+plugin.name+"/modelos/"+elem+"_model.py").model(

						config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/"+elem,
							config.base_root+config.modelos_folder+"request/","user",ext=".py"
							)
						



		for elem in plugin.shortcodes:
					
					self.shortcodes[elem]=imp.load_source(elem+"_model",config.base_root+config.plugins_folder+self.plugin.name+"/shortcodes/"+elem+".py").shortcode(self)
					
					self.shortcodes[elem].ruta=self.plugin.__path__+"/widgets/"

					self.shortcodes[elem].url=config.base_url+config.plugins_folder+"/".join(self.plugin.__path__.split("/")[-2:])+"/widgets/"
					

	def sc(self):
			"""
			invoca los shotcodes atrabes de una url
			"""
			
			if len(self.data["args"])>0:
				self.HEADERS.set_headers({"Content-type":"text/html\n"})
				self.HEADERS.show()
				
				print self.incluir(self.data,"head",isglobal=True)

			atts=""
			if "sc" in self.data:
				atts+=" sc='"+self.data["sc"]+"'"
			
			print self.do_shortcode("["+self.plugin.name+"-"+self.data["args"][0]+atts+"]")

	def metodo_desconocido(self):
		pass
		
	def desinstalar(self,data):
		l=self.plugin.navegacion
		if self.data["model"]["main"].request():
			for k,elem in enumerate(self.data["model"]["main"].obtenerFilas("Plugins")):
				if elem[0]==self.plugin.name:
					self.data["model"]["main"].db("Plugins").modificarCampo(k,"Activo",False)
				
			for k,elem in enumerate(self.data["model"]["main"].obtenerFilas("AdminMenu")):
						if elem in l:
							self.db("AminMenu").delFila(k)
		self.data["model"]["main"].grabar()
		

	def action(self,data):
		pass
Exemple #14
0
    def __init__(self, data):
        from modulos.ztec.zred import Headers
        self.HEADERS = Headers()

        self.models = {}
        self.data = data
        self.HEADERS.show()

        self.app_models = self.data["model"]
        for w in plugin_settings.widgets:

            generar2(
                global_config.base_root + global_config.plugins_folder +
                __name__ + "/widgets/" + w + ".html",
                global_config.base_root + global_config.plugins_folder +
                __name__ + "/widgets/" + w + ".py",
                "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n")

        for elem in plugin_settings.modelos:

            if os.path.exists(config.base_root + config.apps_folder +
                              settings.app + "/admin/" + routes.models_folder +
                              "plugins/" + __name__ + "/"):

                self.models[elem] = imp.load_source(
                    elem + "_model", config.base_root + config.plugins_folder +
                    __name__ + "/modelos/" + elem + "_model.py").model(
                        config.base_root + config.apps_folder + settings.app +
                        "/admin/" + routes.models_folder + "plugins/" +
                        __name__ + "/" + elem,
                        "../../request/",
                        "user",
                        ext=".py")

            else:

                os.mkdir(config.base_root + config.apps_folder + settings.app +
                         "/admin/" + routes.models_folder + "plugins/" +
                         __name__ + "/")

                f = open(
                    config.base_root + config.plugins_folder + __name__ +
                    "/modelos/" + elem + "_struct.py", "r")
                struct = f.read()
                f.close()

                f = open(
                    config.base_root + config.apps_folder + settings.app +
                    "/admin/" + routes.models_folder + "plugins/" + __name__ +
                    "/" + elem + "_struct.py", "w")
                f.write(struct)
                f.close()
                self.models[elem] = imp.load_source(
                    elem + "_model", config.plugins_folder + __name__ +
                    "/modelos/" + elem + "_model.py").model(
                        config.base_root + config.apps_folder + settings.app +
                        "/admin/" + routes.models_folder + "plugins/" +
                        __name__ + "/" + elem,
                        "../request/",
                        "user",
                        ext=".py")

            self.models[elem].models = modelos

        self.shortcodes = {}

        for elem in plugin_settings.shortcodes:

            self.shortcodes[elem] = imp.load_source(
                elem + "_model", config.base_root + config.plugins_folder +
                __name__ + "/shortcodes/" + elem + ".py").shortcode(
                    self.data, self.models)
            self.shortcodes[elem].ruta = "/".join(
                __file__.split("/")[:-1]) + "/widgets/"
            self.url = config.base_url + config.plugins_folder + __file__.split(
                "/")[-2:-1] + "/widgets/"
Exemple #15
0
	def __init__(self,data):      
	  
	  self.data=data
	  

	  self.request=data["request"] 
	  self.isglobal=False
	  self.admin=False

	  self.servida=False
	  self.plugins=data["plugins"]

	  self.vista=None

	  self.tabla="Paginas"
	  self.embebed=None

	  self.model_name="paginas"
	  self.vistas=[]
	  self.ruta_html=""
	  self.ruta_python=""
	  self.HEADERS=Headers()
	  
	  

	  

	  self.zt=None
	  if self.data["app"]!=None:

	  	import settings.config as settings
	  	
	  	
	  	import settings.routes as routes


	  	self.ruta_widget=config.base_root+config.apps_folder+settings.app+"/user/"+routes.vistas_folder
	  	self.ruta_python=self.ruta_html+routes.templates_folder
	  	from ztec.zt import ZT
	  	self.zt=ZT(config.base_root+(config.apps_folder if data["manager"]==False else config.projects_folder)+settings.app+"/admin/"+routes.models_folder+routes.traducciones_folder+"traducciones-"+settings.lang.upper(),"request/",data["token"] if "token" in data else "user",ext=".py")
	  self.data_temp={}


	  


	  for elem in data:
	    if type(elem)==int:
	      self.data_temp[elem]=data[elem]
	    elif type(elem)==str:
	      self.data_temp[elem]=data[elem]
	    elif type(elem)==bool:
	      self.data_temp[elem]=data[elem]
	    elif type(elem)==float:
	      self.data_temp[elem]=data[elem]
	    elif type(elem)==dict:
	      self.data_temp[elem]=data[elem]
	    elif type(elem)==list:
	      self.data_temp[elem]=data[elem]
	    elif type(elem)==tuple:
	      self.data_temp[elem]=data[elem]
Exemple #16
0
 def __init__(self, data):
     self.data = data
     self.HEADERS = Headers()
     self.HEADERS.set_headers({"Content-type": "text/plain\n"})
     if data["control"] != None and data["control"] in dir(self):
         exec("self." + data["control"] + "()")
#print "Content-type: text/plain\n"

try:
    #===============================
    #LIBRERIAS
    import os
    import sys

    sys.path.append("../")

    from config import config

    from modulos.ztec.Asenzor import Asenzor

    from modulos.ztec.zred import Headers

    sys.path.append(config.base_root + "modulos/ztec")
    HEADERS = Headers()

    #======================================

    fmk = Asenzor()

    fmk.run()
    #================================

except Exception, e:
    HEADERS.show()
    print e