Deprecating modules
This commit is contained in:
parent
81847b6e00
commit
eb91ef59bd
5 changed files with 31 additions and 19 deletions
|
|
@ -52,7 +52,7 @@ def prepare_app():
|
||||||
module_loaded=None
|
module_loaded=None
|
||||||
|
|
||||||
#Getting paths for loaded modules for use in media load files
|
#Getting paths for loaded modules for use in media load files
|
||||||
|
"""
|
||||||
for module in config.modules:
|
for module in config.modules:
|
||||||
|
|
||||||
#controller_path=sys.modules[module]
|
#controller_path=sys.modules[module]
|
||||||
|
|
@ -62,6 +62,7 @@ def prepare_app():
|
||||||
base_module=module.split('.')[-1]
|
base_module=module.split('.')[-1]
|
||||||
|
|
||||||
arr_module_path[base_module]=controller_base
|
arr_module_path[base_module]=controller_base
|
||||||
|
"""
|
||||||
|
|
||||||
#app.add_hook('before_request', print_memory)
|
#app.add_hook('before_request', print_memory)
|
||||||
"""
|
"""
|
||||||
|
|
@ -80,7 +81,7 @@ def prepare_app():
|
||||||
app_mounts={}
|
app_mounts={}
|
||||||
|
|
||||||
for key_app, added_app in config.apps.items():
|
for key_app, added_app in config.apps.items():
|
||||||
print(added_app)
|
|
||||||
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__)
|
||||||
|
|
@ -97,18 +98,20 @@ def prepare_app():
|
||||||
|
|
||||||
a=import_module(module_app)
|
a=import_module(module_app)
|
||||||
|
|
||||||
|
if added_app[1]!='':
|
||||||
|
|
||||||
app_name=getattr(a, added_app[1])
|
app_name=getattr(a, added_app[1])
|
||||||
|
|
||||||
#app.register_blueprint(app_name, url_prefix=added_app[2])
|
|
||||||
|
|
||||||
#app.mount(added_app[2], app_name)
|
|
||||||
app_mounts[added_app[2]]=app_name
|
app_mounts[added_app[2]]=app_name
|
||||||
|
|
||||||
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__)
|
||||||
|
|
||||||
for k_app,v_app in app_mounts.items():
|
for k_app,v_app in app_mounts.items():
|
||||||
|
#print(k_app)
|
||||||
|
if k_app!='/':
|
||||||
app.mount(k_app, v_app)
|
app.mount(k_app, v_app)
|
||||||
|
elif k_app!='':
|
||||||
|
app.merge(v_app)
|
||||||
|
|
||||||
set_timezone()
|
set_timezone()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ def session_plugin(callback):
|
||||||
except:
|
except:
|
||||||
session=Session()
|
session=Session()
|
||||||
|
|
||||||
|
if 'session' in kwargs:
|
||||||
kwargs['session']=session
|
kwargs['session']=session
|
||||||
|
|
||||||
#For compatibility with old sessions server-side style.
|
#For compatibility with old sessions server-side style.
|
||||||
|
|
@ -65,7 +66,7 @@ def session_plugin(callback):
|
||||||
rv=callback(*args, **kwargs)
|
rv=callback(*args, **kwargs)
|
||||||
|
|
||||||
if session.changed:
|
if session.changed:
|
||||||
print('changed')
|
#print('changed')
|
||||||
if not safe:
|
if not safe:
|
||||||
safe=URLSafeTimedSerializer(config.key_encrypt)
|
safe=URLSafeTimedSerializer(config.key_encrypt)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
from paramecio.libraries.i18n import I18n
|
from paramecio.libraries.i18n import I18n
|
||||||
from bottle import get,response,request
|
from bottle import get,response,request
|
||||||
from paramecio.libraries.sessions import get_session
|
#from paramecio.libraries.sessions import get_session
|
||||||
|
from paramecio.libraries.sessionplugin import get_session, session_plugin
|
||||||
from paramecio.libraries.urls import redirect
|
from paramecio.libraries.urls import redirect
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@get('/change_lang/<lang>')
|
@get('/change_lang/<lang>')
|
||||||
|
@session_plugin
|
||||||
def index(lang):
|
def index(lang):
|
||||||
|
|
||||||
if lang in I18n.dict_i18n:
|
if lang in I18n.dict_i18n:
|
||||||
|
|
@ -12,8 +14,7 @@ def index(lang):
|
||||||
s=get_session()
|
s=get_session()
|
||||||
|
|
||||||
s['lang']=lang
|
s['lang']=lang
|
||||||
|
#s.save()
|
||||||
s.save()
|
|
||||||
|
|
||||||
redirect_url=request.headers.get('Referer')
|
redirect_url=request.headers.get('Referer')
|
||||||
|
|
||||||
|
|
@ -23,5 +24,7 @@ def index(lang):
|
||||||
|
|
||||||
redirect(redirect_url)
|
redirect(redirect_url)
|
||||||
|
|
||||||
return ""
|
return {'error': 1, 'message': 'No referer for redirect'}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
from bottle import Bottle
|
||||||
|
|
||||||
|
welcome_app=Bottle()
|
||||||
|
|
@ -4,25 +4,27 @@ from paramecio.libraries.mtemplates import PTemplate, env_theme
|
||||||
from paramecio.libraries.urls import make_url
|
from paramecio.libraries.urls import make_url
|
||||||
from paramecio.wsgiapp import app
|
from paramecio.wsgiapp import app
|
||||||
from settings import config
|
from settings import config
|
||||||
|
from paramecio.modules.welcome import welcome_app
|
||||||
|
from bottle import request
|
||||||
|
|
||||||
#t=ptemplate(__file__)
|
#t=ptemplate(__file__)
|
||||||
env=env_theme(__file__)
|
env=env_theme(__file__)
|
||||||
|
|
||||||
t=PTemplate(env)
|
t=PTemplate(env)
|
||||||
|
|
||||||
@app.route('/welcome')
|
@welcome_app.route('/welcome')
|
||||||
def home():
|
def home():
|
||||||
|
|
||||||
return t.render_template('welcome.html', title="Welcome to Paramecio!!!", content="The simple web framework writed in Python3!!!")
|
return t.render_template('welcome.html', title="Welcome to Paramecio!!!", content="The simple web framework writed in Python3!!!")
|
||||||
|
|
||||||
@app.route('/welcome/<id:int>')
|
@welcome_app.route('/welcome/<id:int>')
|
||||||
def page(id):
|
def page(id):
|
||||||
return t.render_template('index.html', title="A simple example of a page", id=id, value=request.query.value)
|
return t.render_template('index.html', title="A simple example of a page", id=id, value=request.query.value)
|
||||||
|
|
||||||
@app.route('/welcome/test/<int_id:int>')
|
@welcome_app.route('/welcome/test/<int_id:int>')
|
||||||
def test(int_id):
|
def test(int_id):
|
||||||
|
|
||||||
return make_url('welcome/test/'+int_id, {'ohmygod': 'This is gooood', 'shutup':'Shut up!!'})
|
return make_url(f'welcome/test/{int_id}', {'ohmygod': 'This is gooood', 'shutup':'Shut up!!'})
|
||||||
|
|
||||||
if config.default_module=="welcome":
|
if config.default_module=="welcome":
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue