Fixes in urls
This commit is contained in:
parent
4a67d7b189
commit
e0ed00af8c
3 changed files with 26 additions and 9 deletions
|
|
@ -3,6 +3,7 @@ from settings import config
|
|||
from importlib import import_module
|
||||
import os
|
||||
import sys
|
||||
import inspect
|
||||
|
||||
def start_app():
|
||||
|
||||
|
|
@ -20,19 +21,27 @@ def start_app():
|
|||
APPLICATION_ROOT=application_root
|
||||
)
|
||||
|
||||
workdir=os.getcwd()
|
||||
arr_module_path={}
|
||||
|
||||
# Load blueprints
|
||||
|
||||
for added_app in config.apps:
|
||||
|
||||
a=import_module(added_app)
|
||||
#print(added_app, file=sys.stdout)
|
||||
app_name=getattr(a, config.apps[added_app][0])
|
||||
module_app=config.apps[added_app][0]
|
||||
|
||||
app.register_blueprint(app_name)
|
||||
a=import_module(module_app)
|
||||
#print(added_app, file=sys.stdout)
|
||||
app_name=getattr(a, config.apps[added_app][1])
|
||||
|
||||
app.register_blueprint(app_name, url_prefix=config.apps[added_app][2])
|
||||
|
||||
arr_module_path[added_app]=os.path.dirname(sys.modules[module_app].__file__)
|
||||
|
||||
#Add media files support. Only for development.
|
||||
|
||||
workdir=os.getcwd()
|
||||
#print(inspect.getmembers(sys.modules['paramecio2.modules.admin.app']))
|
||||
#print(os.path.dirname(sys.modules['paramecio2.modules.admin.app'].__file__))
|
||||
|
||||
@app.route('/mediafrom/<module>/<path:media_file>')
|
||||
def send_media_file(module, media_file):
|
||||
|
|
@ -40,7 +49,8 @@ def start_app():
|
|||
file_path=workdir+'/themes/'+config.theme+'/media/'+module+'/'+media_file
|
||||
|
||||
if not os.path.isfile(file_path):
|
||||
file_path=workdir+'/modules/'+module+'/media/'+media_file
|
||||
#file_path=workdir+'/modules/'+module+'/media/'+media_file
|
||||
file_path=arr_module_path[module]+'/media/'+media_file
|
||||
|
||||
if not os.path.isfile(file_path):
|
||||
abort(404)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
# Template frontend from mako.
|
||||
|
||||
from mako.template import Template
|
||||
from flask import session
|
||||
from flask import session, url_for
|
||||
from mako.lookup import TemplateLookup
|
||||
from os import path
|
||||
from settings import config
|
||||
import gettext
|
||||
import sys
|
||||
from paramecio2.libraries.i18n import I18n
|
||||
from paramecio2.libraries.urls import make_url, make_media_url
|
||||
|
||||
def env_theme(module, cache_enabled=True, cache_impl='', cache_args={}, module_directory="./tmp/modules"):
|
||||
|
||||
|
|
@ -48,6 +49,12 @@ class PTemplate:
|
|||
|
||||
self.add_filter(I18n.lang)
|
||||
|
||||
self.add_filter(make_url)
|
||||
|
||||
self.add_filter(make_media_url)
|
||||
|
||||
self.add_filter(url_for)
|
||||
|
||||
"""
|
||||
def gettext(self, text):
|
||||
return gettext.dgettext(self.domain_gettext, text)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from settings import config
|
||||
from paramecio.cromosoma.webmodel import WebModel
|
||||
from paramecio.cromosoma import corefields
|
||||
from paramecio2.libraries.db.webmodel import WebModel
|
||||
from paramecio2.libraries.db import corefields
|
||||
import unittest
|
||||
# Create TestWebModelMethods
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue