Ejemplo n.º 1
0
    def __init__(self, data):
        Controlador.__init__(self, data)

        self.data["vars"]["table-headers"] = [
            "Nombre", "Ultima modificación", "Descripción"
        ]
        self.data["vars"]["pag"] = 1
Ejemplo n.º 2
0
    def __init__(self, data, headers=None):

        Controlador.__init__(self, data, headers)

        self.vista = "portafolio"

        if data["metodo"] == None and data["action"] == None:

            self.servir()
        self.modelo = data["model"]["paginas"]
Ejemplo n.º 3
0
    def __init__(self, data):
        Controlador.__init__(self, data)

        self.vista = "index"

        if data["metodo"] == None and data["control"] == None and data[
                "action"] == None:
            self.servir()
        self.modelo = data["model"]["paginas"]
        self.vistas = []
Ejemplo n.º 4
0
    def __init__(self, data):
        from modulos.ztec.zred import getCookie, normalizar

        Controlador.__init__(self, data)

        if self.data["action"] == "menus":
            self.data["Paginas"] = self.data["model"][
                "paginas"].obtenerMetadatos("Paginas")
            self.data["Menus"] = self.data["model"]["menus"].obtenerFilas(
                "Menus")
            self.data["Entradas"] = self.data["model"][
                "paginas"].obtenerMetadatos("Entradas")
            self.data["Categorias"] = self.data["model"][
                "paginas"].obtenerMetadatos("Categorias")

            self.data["other-tags"] = []
            self.data["vars"]["Menus"] = self.data["Menus"]
Ejemplo n.º 5
0
 def __init__(self, data):
     from modulos.ztec.zred import getCookie, normalizar
     Controlador.__init__(self, data)
Ejemplo n.º 6
0
	def __init__(self,data):
		
		Controlador.__init__(self,data)
Ejemplo n.º 7
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/"
Ejemplo n.º 8
0
    def __init__(self, data):

        from modulos.ztec.zred import getCookie, normalizar, renderTree
        from modulos.ztec import zu
        Controlador.__init__(self, data)
        self.data = data

        #-------------------------------------------------
        #SECCION DE CONTROL DE USUARIO
        cookies = getCookie()
        token2 = None

        tokens = {}
        folder = os.getcwd().replace("\\", "/").split("/")[-2]
        cookie = Cookie.SimpleCookie()

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

            from settings import config as settings
            from settings import routes

            if "token" in cookies:
                tokens = normalizar(cookies["token"]) if normalizar(
                    cookies["token"]) != "" else {}
            if "token2" in cookies:
                token2 = normalizar(cookies["token2"])

            if settings.app in tokens and (token2 == None or token2 == ""):

                self.data["token"] = tokens[settings.app]

                if data["model"]["usuarios"].isUser(
                        token=tokens[settings.app]
                ) and data["model"]["usuarios"].consultarLogin(
                        tokens[settings.app]):

                    self.data["user"] = data["model"]["usuarios"].getUser(
                        self.data["token"])

                    self.data["login"] = True
                    self.data["isGlobalUser"] = False

                else:

                    self.data["login"] = False

                    cookie["token2"] = ""
                    cookie["token2"]["path"] = "/" + (
                        folder if folder != config.host_folder else "")
                    cookie["token"] = ""
                    cookie["token"]["path"] = "/" + (
                        folder if folder != config.host_folder else "")

                    print cookie

            elif token2 != None and data["model"]["global"].consultarLogin(
                    token2):
                self.data["token"] = token2
                self.data["user"] = data["model"]["global"].getUser(
                    self.data["token"])
                self.data["login"] = True
                self.data["isGlobalUser"] = True
            elif data["app"] == settings.app:

                self.data["login"] = False

                cookie["token2"] = ""
                cookie["token2"]["path"] = "/" + (
                    folder if folder != config.host_folder else "")
                cookie["token"] = ""
                cookie["token"]["path"] = "/" + (
                    folder if folder != config.host_folder else "")
                print cookie

            for elem in self.data["model"]:
                if "token" in data:
                    self.data["model"][elem].token = self.data["token"]
                else:
                    self.data["model"][elem].token = "user"
            self.data["cookies"] = cookies
            self.isglobal = True

            if "token" in data:
                user = self.data["model"]["usuarios"].getUser(
                    self.data["token"])

                if self.data["user"] == {}:
                    self.data["user"] = self.data["model"]["global"].getUser(
                        self.data["token"])
Ejemplo n.º 9
0
    def __init__(self, data):

        Controlador.__init__(self, data)
        self.vista = "Blog"