Пример #1
0
    def Show(self):
        self.HEADERS.set_headers({"Content-type": "text/plain"})
        self.HEADERS.show()
        from modulos.ztec.intervalor.control import generar2
        import os

        if self.data["login"]:

            if "db" in normalizar(self.data["kwargs"]):
                """
		     Muestra contenido directamente desde la base de datos
		     """
                if "id" in normalizar(self.data["kwargs"]) and normalizar(
                        self.data["kwargs"])["id"] != None:
                    tabla = None
                    for elem in list(self.data["model"]["main"].db.tablas):
                        if len(self.data["model"]["main"].db.tablas[elem]) > 0:
                            temp = self.data["model"]["main"].db(
                                elem).obtenerFilaValores(0)
                            if len(temp) > 2:
                                if normalizar(
                                        self.data["kwargs"])["tabla"] == list(
                                            temp[2])[0]:
                                    tabla = elem
                    if tabla != None:
                        print self.data["model"][normalizar(
                            self.data["kwargs"])["db"]].obtenerFilas(tabla)[
                                normalizar(self.data["kwargs"])["id"]]

                else:

                    if normalizar(self.data["kwargs"])["tabla"] in list(
                            self.data["model"]["main"].db.tablas):

                        for elem in list(self.data["model"]["main"].db.tablas):

                            if len(self.data["model"]
                                   ["main"].db.tablas[elem]) > 0:

                                temp = self.data["model"]["main"].db(
                                    elem).obtenerFilaValores(0)

                                if len(temp) > 2:

                                    if normalizar(self.data["kwargs"]
                                                  )["tabla"] == list(
                                                      temp[2])[0]:

                                        tabla = elem
                        print self.data["model"][normalizar(
                            self.data["kwargs"])["db"]].obtenerFilas(
                                normalizar(self.data["kwargs"])["tabla"])
                    else:
                        print self.data["model"][normalizar(
                            self.data["kwargs"])["db"]].obtenerFilas(
                                normalizar(self.data["kwargs"])["tabla"])

            if len(self.data["args"]) > 2:
                """
		    	Muestra el codigo de diseños, modelos y controladores
		    	"""

                if self.data["args"][0] == "layout":
                    if self.data["args"][1] == "user":

                        if os.path.exists(config.base_root +
                                          config.apps_folder + settings.app +
                                          "/user/" + routes.vistas_folder +
                                          "/".join(self.data["args"][2:])):

                            if self.data["action"] == None or self.data[
                                    "action"] == "router":
                                print config.base_root + config.apps_folder + settings.app + "/user/" + routes.vistas_folder + "/".join(
                                    self.data["args"][2:])
                            if self.data["action"] == None or self.data[
                                    "action"] == "incluir":
                                f = open(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/user/" +
                                    routes.vistas_folder +
                                    "/".join(self.data["args"][2:]), "r")
                                print f.read()
                                f.close()
                            elif self.data["action"] == "componer":
                                ext = self.data["args"][-1].split(".")[-1]

                                generar2(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/user/" +
                                    routes.vistas_folder +
                                    "/".join(self.data["args"][2:]),
                                    config.base_root + config.apps_folder +
                                    settings.app + "/user/" +
                                    routes.vistas_folder +
                                    (routes.templates_folder if
                                     self.data["args"][2] != routes.widgets_dir
                                     else "") + "/".join(
                                         self.data["args"][2:])[:-len(ext)] +
                                    "py")
                                f = open(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/user/" +
                                    routes.vistas_folder +
                                    (routes.templates_folder if
                                     self.data["args"][2] != routes.widgets_dir
                                     else "") + "/".join(
                                         self.data["args"][2:])[:-len(ext)] +
                                    "py", "r")
                                print f.read()
                                f.close()

                        else:
                            print None
                    elif self.data["args"][1] == "admin":
                        if os.path.exists(config.base_root +
                                          config.apps_folder + settings.app +
                                          "/admin/" + routes.vistas_folder +
                                          "/".join(self.data["args"][2:])):
                            if self.data["action"] == None or self.data[
                                    "action"] == "router":
                                print config.base_root + config.apps_folder + settings.app + "/admin/" + routes.vistas_folder + "/".join(
                                    self.data["args"][2:])
                            if self.data["action"] == None or self.data[
                                    "action"] == "incluir":
                                f = open(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/admin/" +
                                    routes.vistas_folder +
                                    "/".join(self.data["args"][2:]), "r")
                                print f.read()
                                f.close()
                            elif self.data["action"] == "componer":
                                ext = self.data["args"][-1].split(".")[-1]
                                generar2(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/admin/" +
                                    routes.vistas_folder +
                                    "/".join(self.data["args"][2:]),
                                    config.base_root + config.apps_folder +
                                    settings.app + "/admin/" +
                                    routes.vistas_folder +
                                    (routes.templates_folder if
                                     self.data["args"][2] != routes.widgets_dir
                                     else "") + "/".join(
                                         self.data["args"][2:])[:-len(ext)] +
                                    "py")
                                f = open(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/admin/" +
                                    routes.vistas_folder +
                                    (routes.templates_folder if
                                     self.data["args"][2] != routes.widgets_dir
                                     else "") + "/".join(
                                         self.data["args"][2:])[:-len(ext)] +
                                    "py", "r")
                                print f.read()
                                f.close()
                        else:
                            print None
                    elif self.data["args"][1] == "global":

                        if os.path.exists(config.base_root +
                                          config.vistas_folder +
                                          "/".join(self.data["args"][2:])):
                            if self.data["action"] == None or self.data[
                                    "action"] == "router":
                                print config.base_root + config.vistas_folder + "/".join(
                                    self.data["args"][2:])
                            if self.data["action"] == None or self.data[
                                    "action"] == "incluir":
                                f = open(
                                    config.base_root + config.vistas_folder +
                                    "/".join(self.data["args"][2:]), "r")
                                print f.read()
                                f.close()
                            elif self.data["action"] == "componer":
                                ext = self.data["args"][-1].split(".")[-1]
                                generar2(
                                    config.base_root + config.vistas_folder +
                                    "/".join(self.data["args"][2:]),
                                    config.base_root + config.vistas_folder +
                                    (routes.templates_folder if
                                     self.data["args"][2] != routes.widgets_dir
                                     else "") + "/".join(
                                         self.data["args"][2:])[:-len(ext)] +
                                    "py")
                                f = open(
                                    config.base_root + config.vistas_folder +
                                    (routes.templates_folder if
                                     self.data["args"][2] != routes.widgets_dir
                                     else "") + "/".join(
                                         self.data["args"][2:])[:-len(ext)] +
                                    "py", "r")
                                print f.read()
                                f.close()

                        else:
                            print None
                        pass

                elif self.data["args"][0] == "controlador":

                    if self.data["args"][1] == "user":
                        if os.path.exists(config.base_root +
                                          config.apps_folder + settings.app +
                                          "/user/" + routes.controller_folder +
                                          "/".join(self.data["args"][2:])):
                            if self.data["action"] == None or self.data[
                                    "action"] == "router":
                                print config.base_root + config.apps_folder + settings.app + "/user/" + routes.controller_folder + "/".join(
                                    self.data["args"][2:])
                            if self.data["action"] == None or self.data[
                                    "action"] == "incluir":
                                f = open(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/user/" +
                                    routes.controller_folder +
                                    "/".join(self.data["args"][2:]), "r")
                                print f.read()
                                f.close()
                            elif self.data["action"] == "componer":
                                """
				    			ext=self.data["args"][-1].split(".")[-1]
				    			generar2(config.base_root+config.apps_folder+settings.app+"/user/"+routes.controller_folder+"/".join(self.data["args"][2:]),config.base_root+config.apps_folder+settings.app+"/user/"+routes.controller_folder+"/".join(self.data["args"][2:])[:-len(ext)]+"py")
				    			f=open(config.base_root+config.apps_folder+settings.app+"/user/"+routes.controller_folder+"/".join(self.data["args"][2:])[:-len(ext)]+"py","r")
				    			print f.read()
				    			f.close()
				    			"""
                        else:
                            print None
                    elif self.data["args"][1] == "global":
                        if os.path.exists(config.base_root +
                                          config.controller_folder +
                                          "/".join(self.data["args"][2:])):
                            if self.data["action"] == None or self.data[
                                    "action"] == "router":
                                print config.base_root + config.controller_folder + "/".join(
                                    self.data["args"][2:])
                            if self.data["action"] == None or self.data[
                                    "action"] == "incluir":
                                f = open(
                                    config.base_root +
                                    config.controller_folder +
                                    "/".join(self.data["args"][2:]), "r")
                                print f.read()
                                f.close()
                            elif self.data["action"] == "componer":
                                """
				    			ext=self.data["args"][-1].split(".")[-1]
				    			generar2(config.base_root+config.apps_folder+settings.app+"/user/"+routes.controller_folder+"/".join(self.data["args"][2:]),config.base_root+config.apps_folder+settings.app+"/user/"+routes.controller_folder+"/".join(self.data["args"][2:])[:-len(ext)]+"py")
				    			f=open(config.base_root+config.apps_folder+settings.app+"/user/"+routes.controller_folder+"/".join(self.data["args"][2:])[:-len(ext)]+"py","r")
				    			print f.read()
				    			f.close()
				    			"""
                        else:
                            print None
                elif self.data["args"][0] == "plugins":

                    if os.path.exists(config.base_root +
                                      config.plugins_folder +
                                      "/".join(self.data["args"][1:])):
                        if self.data["action"] == None or self.data[
                                "action"] == "router":
                            print config.base_root + config.plugins_folder + "/".join(
                                self.data["args"][1:])
                        if self.data["action"] == None or self.data[
                                "action"] == "incluir":
                            f = open(
                                config.base_root + config.plugins_folder +
                                "/".join(self.data["args"][1:]), "r")
                            print f.read()
                            f.close()
                        elif self.data["action"] == "componer":

                            ext = self.data["args"][-1].split(".")[-1]
                            _ext = self.data[
                                "ext"] if "ext" in self.data else "py"
                            generar2(
                                config.base_root + config.plugins_folder +
                                "/".join(self.data["args"][1:]),
                                config.base_root + config.plugins_folder +
                                "/".join(self.data["args"][1:])[:-len(ext)] +
                                _ext)
                            f = open(
                                config.base_root + config.plugins_folder +
                                "/".join(self.data["args"][1:])[:-len(ext)] +
                                _ext, "r")
                            print f.read()
                            f.close()

                    else:
                        print None

                elif self.data["args"][0] == "modelo":
                    if self.data["args"][1] == "admin":
                        if os.path.exists(config.base_root +
                                          config.apps_folder + settings.app +
                                          "/admin/" + routes.models_folder +
                                          "/".join(self.data["args"][2:])):
                            if self.data["action"] == None or self.data[
                                    "action"] == "router":
                                print config.base_root + config.apps_folder + settings.app + "/admin/" + routes.models_folder + "/".join(
                                    self.data["args"][2:])
                            if self.data["action"] == None or self.data[
                                    "action"] == "incluir":
                                f = open(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/admin/" +
                                    routes.models_folder +
                                    "/".join(self.data["args"][2:]), "r")
                                print f.read()
                                f.close()
                            elif self.data["action"] == "componer":
                                ext = self.data["args"][-1].split(".")[-1]
                                generar2(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/admin/" +
                                    routes.models_folder +
                                    "/".join(self.data["args"][2:]),
                                    config.base_root + config.apps_folder +
                                    settings.app + "/admin/" +
                                    routes.models_folder + "/".join(
                                        self.data["args"][2:])[:-len(ext)] +
                                    "py")
                                f = open(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/admin/" +
                                    routes.models_folder + "/".join(
                                        self.data["args"][2:])[:-len(ext)] +
                                    "py", "r")
                                print f.read()
                                f.close()
                        else:
                            print None
                    elif self.data["args"][1] == "global":

                        if os.path.exists(config.base_root +
                                          config.modelos_folder +
                                          "/".join(self.data["args"][2:])):
                            if self.data["action"] == None or self.data[
                                    "action"] == "router":
                                print config.base_root + config.modelos_folder + "/".join(
                                    self.data["args"][2:])
                            if self.data["action"] == None or self.data[
                                    "action"] == "incluir":
                                f = open(
                                    config.base_root + config.modelos_folder +
                                    "/".join(self.data["args"][2:]), "r")
                                print f.read()
                                f.close()
                            elif self.data["action"] == "componer":
                                ext = self.data["args"][-1].split(".")[-1]
                                generar2(
                                    config.base_root + config.modelos_folder +
                                    "/".join(self.data["args"][2:]),
                                    config.base_root + config.modelos_folder +
                                    "/".join(self.data["args"][2:])[:-len(ext)]
                                    + "py")
                                f = open(
                                    config.base_root + config.modelos_folder +
                                    "/".join(self.data["args"][2:])[:-len(ext)]
                                    + "py", "r")
                                print f.read()
                                f.close()
                        else:
                            print None
                elif self.data["args"][0] == "static":
                    if self.data["args"][1] == "user":
                        if os.path.exists(config.base_root +
                                          config.apps_folder + settings.app +
                                          "/user/" + routes.static_folder +
                                          "/".join(self.data["args"][2:])):
                            if self.data["action"] == None or self.data[
                                    "action"] == "router":
                                print config.base_root + config.apps_folder + settings.app + "/user/" + routes.static_folder + "/".join(
                                    self.data["args"][2:])
                            if self.data["action"] == None or self.data[
                                    "action"] == "incluir":
                                f = open(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/user/" +
                                    routes.static_folder +
                                    "/".join(self.data["args"][2:]), "r")
                                print f.read()
                                f.close()
                            elif self.data["action"] == "componer":
                                ext = self.data["args"][-1].split(".")[-1]
                                _ext = "py" if "ext" not in self.data else self.data[
                                    "ext"]
                                generar2(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/user/" +
                                    routes.static_folder +
                                    "/".join(self.data["args"][2:]),
                                    config.base_root + config.apps_folder +
                                    settings.app + "/user/" +
                                    routes.static_folder + "/".join(
                                        self.data["args"][2:])[:-len(ext)] +
                                    _ext)
                                f = open(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/user/" +
                                    routes.static_folder + "/".join(
                                        self.data["args"][2:])[:-len(ext)] +
                                    _ext, "r")
                                print f.read()
                                f.close()

                        else:
                            print None
                    elif self.data["args"][1] == "admin":
                        if os.path.exists(config.base_root +
                                          config.apps_folder + settings.app +
                                          "/admin/" + routes.static_folder +
                                          "/".join(self.data["args"][2:])):
                            if self.data["action"] == None or self.data[
                                    "action"] == "router":
                                print config.base_root + config.apps_folder + settings.app + "/admin/" + routes.static_folder + "/".join(
                                    self.data["args"][2:])
                            if self.data["action"] == None or self.data[
                                    "action"] == "incluir":
                                f = open(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/admin/" +
                                    routes.static_folder +
                                    "/".join(self.data["args"][2:]), "r")
                                print f.read()
                                f.close()
                            elif self.data["action"] == "componer":
                                ext = self.data["args"][-1].split(
                                    "."
                                )[-1] if "ext" not in self.data else self.data[
                                    "ext"]
                                _ext = "py" if "ext" not in self.data else self.data[
                                    "ext"]
                                generar2(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/admin/" +
                                    routes.static_folder +
                                    "/".join(self.data["args"][2:]),
                                    config.base_root + config.apps_folder +
                                    settings.app + "/admin/" +
                                    routes.static_folder + "/".join(
                                        self.data["args"][2:])[:-len(ext)] +
                                    _ext)
                                f = open(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/admin/" +
                                    routes.static_folder + "/".join(
                                        self.data["args"][2:])[:-len(ext)] +
                                    _ext, "r")
                                print f.read()
                                f.close()
                        else:
                            print None
                    elif self.data["args"][1] == "global":
                        if os.path.exists(config.base_root +
                                          config.static_folder +
                                          "/".join(self.data["args"][2:])):
                            if self.data["action"] == None or self.data[
                                    "action"] == "router":
                                print config.base_root + config.static_folder + "/".join(
                                    self.data["args"][2:])
                            if self.data["action"] == None or self.data[
                                    "action"] == "incluir":
                                f = open(
                                    config.base_root + config.static_folder +
                                    "/".join(self.data["args"][2:]), "r")
                                print f.read()
                                f.close()
                            elif self.data["action"] == "componer":
                                ext = self.data["args"][-1].split(".")[-1]
                                _ext = "py" if "ext" not in self.data else self.data[
                                    "ext"]
                                generar2(
                                    config.base_root + config.static_folder +
                                    "/".join(self.data["args"][2:]),
                                    config.base_root + config.static_folder +
                                    "/".join(self.data["args"][2:])[:-len(ext)]
                                    + _ext)
                                f = open(
                                    config.base_root + config.static_folder +
                                    "/".join(self.data["args"][2:])[:-len(ext)]
                                    + _ext, "r")
                                print f.read()
                                f.close()

                        else:
                            print None
                elif self.data["args"][0] == "ajustes":

                    if self.data["args"][1] == "admin":
                        if os.path.exists(config.base_root +
                                          config.apps_folder + settings.app +
                                          "/admin/settings/" +
                                          "/".join(self.data["args"][2:])):
                            if self.data["action"] == None or self.data[
                                    "action"] == "router":
                                print config.base_root + config.apps_folder + settings.app + "/admin/settings/" + "/".join(
                                    self.data["args"][2:])
                            if self.data["action"] == None or self.data[
                                    "action"] == "incluir":
                                f = open(
                                    config.base_root + config.apps_folder +
                                    settings.app + "/admin/settings/" +
                                    "/".join(self.data["args"][2:]), "r")
                                print f.read()
                                f.close()

                        else:
                            print None
                    elif self.data["args"][1] == "global":
                        if os.path.exists(config.base_root + "config/" +
                                          "/".join(self.data["args"][2:])):
                            if self.data["action"] == None or self.data[
                                    "action"] == "router":
                                print config.base_root + "config/" + "/".join(
                                    self.data["args"][2:])
                            if self.data["action"] == None or self.data[
                                    "action"] == "incluir":
                                f = open(
                                    config.base_root + "config/" +
                                    "/".join(self.data["args"][2:]), "r")
                                print f.read()
                                f.close()

                        else:
                            print None

                elif self.data["args"][0] == "path":
                    if self.data["args"][1] == "admin":
                        if self.data["args"][2] == "layouts":
                            print config.base_root + config.apps_folder + settings.app + "/admin/" + routes.vistas_folder
                        elif self.data["args"][2] == "widgets":
                            print config.base_root + config.apps_folder + settings.app + "/admin/" + routes.vistas_folder + routes.widgets_folder
                        elif self.data["args"][2] == "modelos":
                            print config.base_root + config.apps_folder + settings.app + "/admin/" + routes.models_folder

                    elif self.data["args"][1] == "user":
                        if self.data["args"][2] == "layouts":
                            print config.base_root + config.apps_folder + settings.app + "/user/" + routes.vistas_folder
                        elif self.data["args"][2] == "widgets":
                            print config.base_root + config.apps_folder + settings.app + "/user/" + routes.vistas_folder + routes.widgets_folder
                        elif self.data["args"][2] == "controladores":
                            print config.base_root + config.apps_folder + settings.app + "/user/" + routes.controller_folder

        else:
            self.HEADERS.show()
            print "None"
        pass
Пример #2
0
	def incluir(self,data={},widget="",modulo="plugin"):
		if data=={}:
			data=self.plugin.data
		plugin=self.plugin.plugin
		
		from modulos.ztec.zred import decode
		from modulos.ztec.intervalor.control import generar2

		if widget!="":
			from config import config
			import os
			

			self.widget=widget
			
			if modulo!="plugin":
				
				if modulo=="admin":
					from settings import config as settings
					from settings import routes

					self.ruta=config.base_root+config.apps_folder+settings.app+"/admin/"+routes.vistas_folder+routes.widgets_folder
				elif modulo=="user":
					self.ruta=config.base_root+config.apps_folder+settings.app+"/user/"+routes.vistas_folder+routes.widgets_folder
				elif modulo=="global":

					self.ruta=config.base_root+config.vistas_folder+config.widgets_folder

				if os.path.exists(self.ruta+self.widget+".html"):
					generar2(self.ruta+self.widget+".html",self.ruta+self.widget+".py","# -*- coding: utf-8 -*-\n")
				elif os.path.exists(self.ruta+self.widget+"/"+self.widget+".html"): 

					self.ruta+=self.widget
					plugin.widget_base_url+=self.widget+"/"
		   
					plugin.widget_url=plugin.widget_base_url+self.widget+".html"
					generar2(self.ruta+self.widget+".html",self.ruta+self.widget+".py","# -*- coding: utf-8 -*-\n")
			   

		incluir=self.incluir






		
		
		if data["app"]!=None:

			from settings import config as settings
			from settings import routes





		if self.widget!=None:
			import os,urllib2,urllib

			from modulos.ztec.zu import filtrar_datos_planos
			from modulos.ztec.intervalor.control import generar3
			from config import config
			plugin.widget_base_url=config.base_url+config.plugins_folder+plugin.name+"/"+plugin.widgets_folder

			if os.path.exists(self.ruta+self.widget+".py"):
			

				f=open(self.ruta+self.widget+".py")



				script=f.read()


				f.close()
				
				doc=""
				try:
					
					exec(script)

					return doc
				except Exception as e:

					return str(e)
			
			elif os.path.exists(self.ruta+self.widget+"/"+self.widget+".py"):
				plugin.widget_base_url+=self.widget
			

				f=open(self.ruta+self.widget+"/"+self.widget+".py")



				script=f.read()


				f.close()
				
				doc=""
				try:
					
					exec(script)

					return doc
				except Exception as e:

					return str(e)

				
			elif self.embebed=="php" and os.path.exists(self.ruta+self.widget+".php"):
				
				
				params=urllib.urlencode({"data":filtrar_datos_planos(self.plugin.data)})
				f=urllib2.urlopen(self.url+self.widget+".php",params)
				return f.read()
			elif self.embebed=="rb" and os.path.exists(self.ruta+self.widget+".html.rb"):
				
				params=urllib.urlencode({"data":filtrar_datos_planos(self.plugin.data)})
				generar3(self.ruta+self.widget+".html.rb",self.ruta+self.widget+".rb",formatear_rb,'#!/usr/bin/env  ruby\nputs "Content-type: text/html\\n\\n"\n')
				
				f=urllib2.urlopen(self.url+self.widget+".rb",params)
				return f.read()
			elif self.embebed=="pl" and os.path.exists(self.ruta+self.widget+".html.pl"):
				
				params=urllib.urlencode({"data":filtrar_datos_planos(self.plugin.data)})
				generar3(self.ruta+self.widget+".html.pl",self.ruta+self.widget+".pl",formatear_pl,'#!/usr/bin/env  perl\nprint "Content-type: text/html\\n\\n";\n')
				f=urllib2.urlopen(self.url+self.widget+".pl",params)
				return f.read()
			elif self.embebed=="sh" and os.path.exists(self.ruta+self.widget+".html.sh"):
				params=urllib.urlencode({"data":filtrar_datos_planos(self.plugin.data)})
				generar3(self.ruta+self.widget+".html.sh",self.ruta+self.widget+".sh",'#!/usr/bin/env  sh\necho "Content-type: text/html\\n\\n";\n')
				f=urllib2.open(self.url+self.widget+".sh",params)
				return f.read()
			elif self.embebed=="asp" and os.path.exists(self.ruta+self.widget+".html.asp"):
				"""
				Necesitara de un servidor
				la extencion es ficticia
				"""
				params=urllib.urlencode({"data":filtrar_datos_planos(self.plugin.data)})
				generar3(self.ruta+self.widget+".html.sh",self.ruta+self.widget+".sh","#!/usr/bin/env  asp\n")
				f=urllib2.open(self.url+self.widget+".sh",params)
				return f.read()
			elif self.embebed=="cpp" and os.path.exists(self.ruta+self.widget+".htm.cpp"):
				"""
				Necesitara de un servidor
				la extencion es ficticia
				"""
				params=urllib.urlencode({"data":filtrar_datos_planos(self.plugin.data)})
				generar3(self.ruta+self.widget+".html.cpp",self.ruta+self.widget+".cpp","#!/usr/bin/env  cpp\n")
				f=urllib2.open(self.url+self.widget+".cpp",params)
				return f.read()
			elif self.embebed=="go" and os.path.exists(self.ruta+self.widget+".go"):
				"""
				Necesitara de un servidor
				la extencion es ficticia
				"""
				params=urllib.urlencode({"data":filtrar_datos_planos(self.plugin.data)})
				f=urllib3.open(self.url+self.widget+".go",params)
				return f.read()
Пример #3
0
class Asenzor:
    """docstring for AsenZor"""
    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"]

        self.data["model"] = {}

        self.data["errores"] = []
        self.data["vars"] = {}

        self.data["plugins"] = {}

        self.data["login"] = False
        self.data["user"] = None
        self.data["isGlobalUser"] = False
        self.data["token"] = None
        self.data["model"]["global"] = model("../modelos/global",
                                             "../modelos/request/",
                                             "user",
                                             ext=".py")

        self.data["opciones"] = {
            "global": self.data["model"]["global"].obtenerFilas("Opciones")
        }
        self.data["plugins-hooks"] = []
        self.data["plugins"] = {}

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

            sys.path.append(config.base_root + config.apps_folder +
                            self.data["app"] + "/")

            from app import app

            self.app = app()

            sys.path.append(self.app.admin.__path__) if (
                self.app.admin.__path__ not in sys.path) else None

            self.data["base_url"] = self.app.user.__url__

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

            settings = self.app.admin.settings

            routes = self.app.admin.routes
            base_root = self.app.admin.__path__

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

            if len(contenido) > 1 and self.data["app"] != None:

                for k, elem in enumerate(contenido[1]):

                    if contenido[1][elem]["value"] in settings.dbs:

                        if os.path.exists(self.app.admin.modelos.__path__ +
                                          str(contenido[1][elem]["value"]) +
                                          "_model.py"):
                            exec("model" + str(k) + "=imp.load_source('model" +
                                 str(k) + "' ,'" +
                                 self.app.admin.modelos.__path__ +
                                 str(contenido[1][elem]["value"]) +
                                 "_model.py').model")

                            exec("self.data['model']['" +
                                 contenido[1][elem]["value"] + "']=model" +
                                 str(k) + "('" +
                                 self.app.admin.modelos.__path__ +
                                 contenido[1][elem]["value"] + "','" +
                                 self.app.admin.modelos.__path__ +
                                 "request/','" + self.data["app"] +
                                 "',ext='.py')")

                            self.data["model"][
                                contenido[1][elem]["value"]].models[
                                    "global"] = self.data["model"]["global"]
                            self.data["model"]["global"].models[contenido[1][
                                elem]["value"]] = self.data["model"][
                                    contenido[1][elem]["value"]]

                            if "Opciones" in self.data["model"][
                                    contenido[1][elem]["value"]].db.tablas:
                                self.data["opciones"][contenido[1][elem][
                                    "value"]] = self.data["model"][
                                        contenido[1][elem]
                                        ["value"]].obtenerFilas("Opciones")
                            if self.data["model"][contenido[1][elem]
                                                  ["value"]].errores != []:
                                self.data["errores"].append(self.data["model"][
                                    contenido[1][elem]["value"]].errores)
                            elif self.data["model"][contenido[1][elem]
                                                    ["value"]].db.errores:
                                self.data["errores"].append(self.data["model"][
                                    contenido[1][elem]["value"]].db.errores)
                    else:
                        self.data["errores"].append(
                            "No se encontro el modelo: " +
                            contenido[1][elem]["value"] + " en el directorio")

                for k, elem in enumerate(contenido[2]):

                    if contenido[2][elem]["value"] in settings.dbs:
                        if os.path.exists("../" + config.modelos_folder +
                                          str(contenido[2][elem]["value"]) +
                                          "_model.py"):

                            exec("model" + str(k) + "=imp.load_source('model" +
                                 str(k) + "' ,'../" + config.modelos_folder +
                                 str(contenido[2][elem]["value"]) +
                                 "_model.py').model")
                            exec("self.data['model']['" +
                                 contenido[2][elem]["value"] + "']=model" +
                                 str(k) + "('" + base_root +
                                 routes.models_folder +
                                 contenido[2][elem]["value"] + "','" +
                                 base_root + routes.models_folder +
                                 "request/','" + self.data["app"] +
                                 "',ext='.py')")
                            self.data["model"][
                                contenido[2][elem]["value"]].models[
                                    "global"] = self.data["model"]["global"]
                            self.data["model"]["global"].models[contenido[2][
                                elem]["value"]] = self.data["model"][
                                    contenido[2][elem]["value"]]
                            if "Opciones" in self.data["model"][
                                    contenido[2][elem]["value"]].db.tablas:
                                self.data["opciones"][contenido[2][elem][
                                    "value"]] = self.data["model"][
                                        contenido[2][elem]
                                        ["value"]].obtenerFilas("Opciones")
                            if self.data["model"][contenido[2][elem]
                                                  ["value"]].errores != []:
                                self.data["errores"].append(self.data["model"][
                                    contenido[2][elem]["value"]].errores)
                            elif self.data["model"][contenido[2][elem]
                                                    ["value"]].db.errores:
                                self.data["errores"].append(self.data["model"][
                                    contenido[2][elem]["value"]].db.errores)
                        else:
                            self.data["errores"].append(
                                "No se encontro el modelo: " +
                                contenido[2][elem]["value"] +
                                " en el directorio")

            plugins = {}

            self.data["base_url"] = self.app.user.__url__

            for elem in self.data["model"]["main"].obtenerFilas("Plugins"):
                plugins[elem[0]] = elem[1]

            for plugin in self.data["model"]["global"].obtenerFilas("Plugins"):

                if plugin[0] in plugins:

                    if plugins[plugin[0]] == True:

                        for elem in plugin[1][1]:
                            self.data["plugins-hooks"].append(
                                [elem["name"], elem["value"]])

                        if os.path.exists(config.base_root +
                                          config.plugins_folder + plugin[0] +
                                          "/default.py"):

                            self.data["plugins"][plugin[0]] = imp.load_source(
                                "", config.base_root + config.plugins_folder +
                                plugin[0] + "/default.py").Plugin(self.data)

                        else:

                            print "El plugin: " + plugin[
                                0] + "No puede ser inicializado"

                else:

                    if self.data["model"]["main"].request():
                        self.data["model"]["main"].db("Plugins").insertar(
                            plugin[0], False)
                        self.data["model"]["main"].grabar()

            self.app.user.cnt(self.data)

        else:

            if self.data["app"] != None:
                sys.path.append(config.base_root + config.apps_folder +
                                self.data["app"] + "/")
                from app import app
                self.app = app()
                sys.path.append(self.app.admin.__path__) if (
                    self.app.admin.__path__ not in sys.path) else None
                self.data["base_url"] = self.app.user.__url__
                from settings import config as settings
                from settings import routes
                base_root = self.app.admin.__path__

                contenido = self.data["model"]["global"].obtenerContenido(
                    self.data["app"], "apps")[self.data["app"]]
                if len(contenido) > 1:
                    for k, elem in enumerate(contenido[1]):

                        if contenido[1][elem]["value"] in settings.dbs:

                            exec("model" + str(k) + "=imp.load_source('model" +
                                 str(k) + "' ,'" +
                                 self.app.admin.modelos.__path__ +
                                 str(contenido[1][elem]["value"]) +
                                 "_model.py').model")

                            exec("self.data['model']['" +
                                 contenido[1][elem]["value"] + "']=model" +
                                 str(k) + "('" +
                                 self.app.admin.modelos.__path__ +
                                 contenido[1][elem]["value"] + "','" +
                                 self.app.admin.modelos.__path__ +
                                 "request/','" + self.data["app"] +
                                 "',ext='.py')")

                            self.data["model"][
                                contenido[1][elem]["value"]].models[
                                    "global"] = self.data["model"]["global"]
                            self.data["model"]["global"].models[contenido[1][
                                elem]["value"]] = self.data["model"][
                                    contenido[1][elem]["value"]]

                            if "Opciones" in self.data["model"][
                                    contenido[1][elem]["value"]].db.tablas:
                                self.data["opciones"][contenido[1][elem][
                                    "value"]] = self.data["model"][
                                        contenido[1][elem]
                                        ["value"]].obtenerFilas("Opciones")
                            if self.data["model"][contenido[1][elem]
                                                  ["value"]].errores != []:
                                self.data["errores"].append(self.data["model"][
                                    contenido[1][elem]["value"]].errores)
                            elif self.data["model"][contenido[1][elem]
                                                    ["value"]].db.errores:
                                self.data["errores"].append(self.data["model"][
                                    contenido[1][elem]["value"]].db.errores)
                    for k, elem in enumerate(contenido[2]):

                        if contenido[2][elem]["value"] in settings.dbs:

                            exec("model" + str(k) + "=imp.load_source('model" +
                                 str(k) + "' ,'../" + config.modelos_folder +
                                 str(contenido[2][elem]["value"]) +
                                 "_model.py').model")
                            exec("self.data['model']['" +
                                 contenido[2][elem]["value"] + "']=model" +
                                 str(k) + "('" + base_root +
                                 routes.models_folder +
                                 contenido[2][elem]["value"] + "','" +
                                 base_root + routes.models_folder +
                                 "request/','" + self.data["app"] +
                                 "',ext='.py')")
                            self.data["model"][
                                contenido[2][elem]["value"]].models[
                                    "global"] = self.data["model"]["global"]
                            self.data["model"]["global"].models[contenido[2][
                                elem]["value"]] = self.data["model"][
                                    contenido[2][elem]["value"]]

                            if "Opciones" in self.data["model"][
                                    contenido[2][elem]["value"]].db.tablas:
                                self.data["opciones"][contenido[2][elem][
                                    "value"]] = self.data["model"][
                                        contenido[2][elem]
                                        ["value"]].obtenerFilas("Opciones")
                            if self.data["model"][contenido[2][elem]
                                                  ["value"]].errores != []:
                                self.data["errores"].append(self.data["model"][
                                    contenido[2][elem]["value"]].errores)
                            elif self.data["model"][contenido[2][elem]
                                                    ["value"]].db.errores:
                                self.data["errores"].append(self.data["model"][
                                    contenido[2][elem]["value"]].db.errores)

            if self.data["manager"] == True and gringolizar(
                    self.data["global_control"]) in config.controladores:

                if self.data["global_control"] == "Plugin":
                    for plugin in self.data["model"]["global"].obtenerFilas(
                            "Plugins"):

                        for elem in plugin[1][1]:
                            self.data["plugins-hooks"].append(
                                [elem["name"], elem["value"]])

                        self.data["plugins"][plugin[0]] = imp.load_source(
                            "", config.base_root + config.plugins_folder +
                            plugin[0] + "/default.py").Plugin(self.data)

                control = imp.load_source(
                    "", config.base_root + config.controller_folder +
                    "Controladores/" +
                    gringolizar(self.data["global_control"]) + ".py")

                exec("control=control." +
                     gringolizar(self.data["global_control"]) + "(self.data)")

                if self.data["metodo"] != None and self.data["metodo"] in dir(
                        control):

                    exec("control." + gringolizar(self.data["metodo"]) + "()")
                """
				Pendiente ya que plugin no lo utilizaria ya que el metodo desconocido des del plugin que carga no del global_control
				elif self.data["metodo"]!=None:
					
					exec("control.metodo_desconocido()")
				"""

            else:
                self.HEADERS.show()

                from modulos.ztec.intervalor.control import generar2
                generar2(
                    config.base_root + config.vistas_folder + self.vista +
                    ".html", config.base_root + config.vistas_folder +
                    config.templates_folder + self.vista + ".py",
                    "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n")
                doc = ""
                f = open(
                    config.base_root + config.vistas_folder +
                    config.templates_folder + self.vista + ".py", "r")
                script = f.read()
                exec(script)
                print doc
Пример #4
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/"
Пример #5
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/"
Пример #6
0
	def servir(self):
	  if self.servida==False:

		  import urllib,urllib2 
		  from modulos.ztec.zu import filtrar_datos_planos	  
		  if self.data["app"]!=None:
		  	import settings.config as settings
		  	import settings.routes as routes
		  	routes.base_url=config.base_url+settings.app+"/"
		  self.servida=True
		  notFound=None

		  

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

		  
		  from ztec.zu import rstr
		  from ztec.zred import HEAD,TITLE,BASE,LINK,META,STYLE,SCRIPT,NOSCRIPT,BODY,SECTION,NAV,ARTICLE,ASIDE,H1,H2,H3,H4,H5,H6,HEADER,FOOTER,ADDRESS,MAIN,P,HR,PRE,BLOCKQUOTE,OL,UL,LI,DL,DT,DD,FIGURE,FIGCAPTION,DIV,A,EM,STRONG,SMALL,S,CITE,Q,DFN,ABBR,DATA,TIME,CODE,VAR,SAMP,KBD,SUB,SUP,I,B,U,MARK,RUBY,RT,RP,BDI,BDO,SPAN,BR,WBR,INS,DEL,IMG,IFRAME,EMBED,OBJECT,PARAM,VIDEO,AUDIO,MAP,AREA,MATH,TABLE,CAPTION,COLGROUP,COL,TR,TD,FORM,FIELDSET,LEGEND,LABEL,INPUT,BUTTON,SELECT,DATALIST,OPTION,TEXTAREA,KEYGEN,OUTPUT,PROGRESS,METER,DETALIST,COMMAND,MENU,SUMMARY
		  if self.data["control"]=="admin":
		  	
		  	routes.layout_base_root=(config.base_root+config.vistas_folder if self.isglobal==True else self.ruta_widget.replace("/user/","/admin/"))
		  	routes.layout_url=(config.base_url+config.vistas_folder if self.isglobal==True else self.ruta_widget.replace("/user/","/admin/"))+self.vista

		  	routes.template_root=(config.base_root+config.vistas_folder if self.isglobal==True else self.ruta_widget.replace("/user/","/admin/"))+routes.templates_folder+self.vista+".py"

		  	routes.layout_base_url=(config.base_url+config.vistas_folder if self.isglobal==True else config.base_url+self.ruta_widget[len(config.base_root):].replace("/user/","/admin/"))
		  else:
		  	routes.layout_base_root=("../"+config.vistas_folder if self.isglobal==True else self.ruta_widget.replace("/admin/","/user/"))
		  	routes.template_root=("../"+config.vistas_folder if self.isglobal==True else self.ruta_widget.replace("/admin/","/user/"))+routes.templates_folder+self.vista+".py"
		  	routes.layout_base_url=(config.base_url+config.vistas_folder if self.isglobal==True else config.base_url+self.ruta_widget[len(config.base_root):].replace("/admin/","/user/"))

		  if os.path.exists(routes.layout_base_root+self.vista+".html") and self.embebed==None:  
		    	routes.layout_root=routes.layout_base_root+self.vista+".html"
		    	routes.layout_url=routes.layout_base_url+self.vista+".html"

		    	
		    	generar2(routes.layout_root,routes.template_root,"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n")
		    	f=open(routes.template_root,"r")
		    	html=f.read() 	
		    	f.close()

		  elif os.path.exists(routes.layout_base_root+self.vista) and self.embebed==None:
	  
		    	routes.layout_root=routes.layout_base_root+self.vista+"/"+self.vista+".html"
		    	routes.layout_url=routes.layout_base_url+self.vista+"/"+self.vista+".html"
		    	generar2(routes.layout_root,routes.template_root,"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n")
		    	f=open(routes.template_root,"r")	   
		    	html=f.read() 	
		    	f.close()

		  elif  self.embebed!=None and os.path.exists(routes.layout_base_root+self.vista+".html."+self.embebed):
		    	routes.layout_root=routes.layout_base_root+self.vista+"/"+self.vista+".html."+self.embebed
		    	routes.layout_url=routes.layout_base_url+self.vista+"/"+self.vista+".html."+self.embebed
		    	routes.template_url=routes.layout_base_url+routes.template_folder+self.vista+"."+self.embebed

		    	generar2(routes.layout_root,routes.template_root,"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n")
		    	f=open(routes.template_root,"r")	
		    	params = urllib.urlencode({"data":filtrar_datos_planos(self.data)})
		    	f=urllib2.urlopen(routes.template_url+self.vista+self.embebed,params)
		    	html=f.read()         
		    	f.close()

		  elif  self.embebed!=None and os.path.exists(routes.layout_base_root+self.vista+"/"+self.vista+".html."+self.embebed):
		    	routes.layout_root=routes.layout_base_root+self.vista+"/"+self.vista+".html."+self.embebed
		    	routes.layout_url=routes.layout_base_url+self.vista+"/"+self.vista+".html."+self.embebed
		    	routes.template_url=routes.layout_base_url+"../"+routes.template_folder+self.vista+"."+self.embebed

		    	generar2(routes.layout_root,routes.template_root,"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n")
		    	f=open(routes.template_root,"r")	
		    	params = urllib.urlencode({"data":filtrar_datos_planos(self.data)})
		    	f=urllib2.urlopen(routes.template_url+self.vista+self.embebed,params)   
		    	notFound=True
		    	html=f.read()         	
		    	f.close()


		  elif os.path.exists(routes.layout_base_root+self.vista+"."+self.embebed if self.embebed!=None else "php"):
		    	if self.embebed==None:
		    		self.embebed="php"
		    	routes.layout_url=routes.layout_base_url
		    	params = urllib.urlencode({"data":filtrar_datos_planos(self.data)})
		    	f=urllib2.urlopen(routes.layout_url+self.vista+self.embebed,params)        
		    	notFound=True
		    	html=f.read()
		    	f.close()
	

		  if notFound==True or self.embebed!=None:
			print html
			return html
		  else:
			  try:

			  
			    self.HEADERS.show()
			    doc=""
			    data=self.data
			    incluir=self.incluir
			    self.ruta_widget=routes.layout_base_root+routes.widgets_folder
			    
			    ruta_widget=self.ruta_widget



			    exec(html)


			    print doc
			    return doc
			    
			  except Exception as e:
			    import traceback

			    

			    try:
			      exc_type,exc_obj,exc_tb=sys.exc_info()
			      fname = exc_tb.tb_frame.f_code.co_filename
			      print "".join(traceback.format_exception(exc_type,fname,exc_tb)).replace("\n","<br>")
			    except:
			      print e
			    
			    
			    if len(e.args)==2:

			      print e,"<br>"
			      print e.args[1][3]


			    else:
			      print e
Пример #7
0
	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
Пример #8
0
	def generar(self,ruta_html,ruta_python,cabeceras):

	  generar2(ruta_html,ruta_python,cabeceras)