Fixes for fix a warning about registering blueprints
This commit is contained in:
parent
8c2bcdc74a
commit
dfbdc7109f
4 changed files with 25 additions and 13 deletions
|
|
@ -38,11 +38,13 @@ def start_app():
|
||||||
for key_app, added_app in config.apps.items():
|
for key_app, added_app in config.apps.items():
|
||||||
|
|
||||||
controller_path=import_module(added_app[0])
|
controller_path=import_module(added_app[0])
|
||||||
|
|
||||||
controller_base=os.path.dirname(controller_path.__file__)
|
controller_base=os.path.dirname(controller_path.__file__)
|
||||||
|
|
||||||
dir_controllers=os.listdir(controller_base)
|
dir_controllers=os.listdir(controller_base)
|
||||||
|
|
||||||
|
app_name=getattr(controller_path, added_app[1])
|
||||||
|
|
||||||
for controller in dir_controllers:
|
for controller in dir_controllers:
|
||||||
|
|
||||||
if controller.find('.py')!=-1 and controller.find('__init__')==-1:
|
if controller.find('.py')!=-1 and controller.find('__init__')==-1:
|
||||||
|
|
@ -50,15 +52,12 @@ def start_app():
|
||||||
controller_py=controller.replace('.py', '')
|
controller_py=controller.replace('.py', '')
|
||||||
|
|
||||||
module_app=added_app[0]+'.'+controller_py
|
module_app=added_app[0]+'.'+controller_py
|
||||||
|
|
||||||
a=import_module(module_app)
|
a=import_module(module_app)
|
||||||
|
|
||||||
app_name=getattr(a, added_app[1])
|
|
||||||
|
|
||||||
app.register_blueprint(app_name, url_prefix=added_app[2])
|
|
||||||
|
|
||||||
arr_module_path[key_app]=os.path.dirname(sys.modules[module_app].__file__)
|
arr_module_path[key_app]=os.path.dirname(sys.modules[module_app].__file__)
|
||||||
|
|
||||||
|
app.register_blueprint(app_name, url_prefix=added_app[2])
|
||||||
|
|
||||||
"""
|
"""
|
||||||
module_app=config.apps[added_app][0]
|
module_app=config.apps[added_app][0]
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,11 @@ class SendMail:
|
||||||
else:
|
else:
|
||||||
self.context = ssl_module.SSLContext(ssl_module.PROTOCOL_TLS)
|
self.context = ssl_module.SSLContext(ssl_module.PROTOCOL_TLS)
|
||||||
|
|
||||||
|
def connect(self):
|
||||||
|
|
||||||
|
self.smtp=smtplib.SMTP(host=self.host, port=self.port)
|
||||||
|
|
||||||
if self.ssl==True:
|
if self.ssl==True:
|
||||||
|
|
||||||
self.smtp=smtplib.SMTP(host=self.host, port=self.port)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
|
@ -61,10 +63,11 @@ class SendMail:
|
||||||
self.txt_error=e.__str__()
|
self.txt_error=e.__str__()
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
#login
|
#login
|
||||||
|
|
||||||
if self.username!='':
|
if self.smtp!=None:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
|
@ -87,9 +90,15 @@ class SendMail:
|
||||||
self.txt_error='Error: any method for login is avaliable - '+e.__str__()
|
self.txt_error='Error: any method for login is avaliable - '+e.__str__()
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def send(self, from_address, to_address: list, subject, message, content_type='plain', attachments=[]):
|
def send(self, from_address, to_address: list, subject, message, content_type='plain', attachments=[]):
|
||||||
|
|
||||||
|
if self.smtp==None:
|
||||||
|
if not self.connect():
|
||||||
|
return False
|
||||||
|
|
||||||
COMMASPACE=', '
|
COMMASPACE=', '
|
||||||
|
|
||||||
if len(attachments)==0:
|
if len(attachments)==0:
|
||||||
|
|
@ -168,6 +177,7 @@ class SendMail:
|
||||||
|
|
||||||
if self.smtp!=None:
|
if self.smtp!=None:
|
||||||
self.smtp.quit()
|
self.smtp.quit()
|
||||||
|
self.smtp=None
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
from flask import Blueprint, redirect
|
||||||
|
|
||||||
|
welcome_app=Blueprint('welcome_app', __name__)
|
||||||
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
from flask import Blueprint, redirect
|
|
||||||
from settings import config
|
from settings import config
|
||||||
from paramecio2.libraries.mtemplates import PTemplate, env_theme
|
from paramecio2.libraries.mtemplates import PTemplate, env_theme
|
||||||
|
from paramecio2.modules.welcome import welcome_app
|
||||||
|
|
||||||
env=env_theme(__file__)
|
env=env_theme(__file__)
|
||||||
|
|
||||||
t=PTemplate(env)
|
t=PTemplate(env)
|
||||||
|
|
||||||
welcome_app=Blueprint('welcome_app', __name__)
|
|
||||||
|
|
||||||
@welcome_app.route('/welcome')
|
@welcome_app.route('/welcome')
|
||||||
def home():
|
def home():
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue