Esempio n. 1
0
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"])
Esempio n. 2
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:
Esempio n. 3
0
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
Esempio n. 4
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
Esempio n. 5
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
Esempio n. 6
0
class Plugin:
    """docstring for Plugin"""
    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/"

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

    def metodo_desconocido(self):
        pass

    def action(self, data):
        global config
Esempio n. 7
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
Esempio n. 8
0
#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