Svo geri ég:
Kóði: Velja allt
import plugins
En mig vantar möguleikan á að setja alla plugin classana í mismunandi skjöl inní ./plugins/ og loada.
Er einhvern vegin ekki að fatta lausnina, nota IMP?
Mitt current setup er svona( pseudo plugins )
Canvas.py
Kóði: Velja allt
import plugins
def Render(self,method,function,variable): # render it function called from system.Render
hex_class =getattr(plugins ,method) # get the class to call
hex_class_inst = hex_class(self.reqHandler) # bind it i think or call the init yada yada yada ### request handler is to be deprecated
hex_funct = getattr(hex_class_inst ,function) # get the function
return hex_funct(variable) # call Plugin with the variable tuple
Og svo inní python-tornado.
Kóði: Velja allt
class RenderHandler(tornado.web.RequestHandler):
def get(self,method,function,variable):
hexer = hex(self)
splitter = variable.split("|")
tuple = []
for item in splitter:
tuple.append(str(item))
todo = hexer.Render(method,function,tuple)
# switch like statement below switch(todo[0])
sample plugin.
Kóði: Velja allt
class user(Thor_plugin):
def get_current_user(self):
if self.handler.get_secure_cookie("username") != None:
return self.handler.get_secure_cookie("username")
else:
return "0"
def __init__(self,handle):
self.handler = handle
super(user,self).__init__(handle)
def login(self,var):
return (3 ,"login.html")
Svo til þess að sýna login
Gerirðu mysite.com/user/login//
Vill geta notað getattr