Fixes for fix a warning about registering blueprints

This commit is contained in:
Antonio de la Rosa 2021-06-28 14:49:01 +02:00
parent 8c2bcdc74a
commit dfbdc7109f
4 changed files with 25 additions and 13 deletions

View file

@ -38,11 +38,13 @@ def start_app():
for key_app, added_app in config.apps.items():
controller_path=import_module(added_app[0])
controller_base=os.path.dirname(controller_path.__file__)
dir_controllers=os.listdir(controller_base)
app_name=getattr(controller_path, added_app[1])
for controller in dir_controllers:
if controller.find('.py')!=-1 and controller.find('__init__')==-1:
@ -50,15 +52,12 @@ def start_app():
controller_py=controller.replace('.py', '')
module_app=added_app[0]+'.'+controller_py
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__)
app.register_blueprint(app_name, url_prefix=added_app[2])
"""
module_app=config.apps[added_app][0]

View file

@ -36,9 +36,11 @@ class SendMail:
else:
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:
self.smtp=smtplib.SMTP(host=self.host, port=self.port)
try:
@ -61,10 +63,11 @@ class SendMail:
self.txt_error=e.__str__()
return False
#login
if self.username!='':
if self.smtp!=None:
try:
@ -87,9 +90,15 @@ class SendMail:
self.txt_error='Error: any method for login is avaliable - '+e.__str__()
return False
return True
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=', '
if len(attachments)==0:
@ -168,6 +177,7 @@ class SendMail:
if self.smtp!=None:
self.smtp.quit()
self.smtp=None
def __del__(self):

View file

@ -0,0 +1,4 @@
from flask import Blueprint, redirect
welcome_app=Blueprint('welcome_app', __name__)

View file

@ -1,13 +1,12 @@
from flask import Blueprint, redirect
from settings import config
from paramecio2.libraries.mtemplates import PTemplate, env_theme
from paramecio2.modules.welcome import welcome_app
env=env_theme(__file__)
t=PTemplate(env)
welcome_app=Blueprint('welcome_app', __name__)
@welcome_app.route('/welcome')
def home():