#!/usr/bin/env python3 #from paramecio.wsgiapp import app from cuchulu.libraries.mtemplates import PTemplate, env_theme from modules.pages2.models.pages import Page2 from cuchulu.libraries.db.webmodel import WebModel from settings import config from bottle import abort #from flask import abort, request from modules.pages2 import pages2_app from cuchulu.libraries.db.coreforms import BaseForm from cuchulu.libraries.mtemplates import env_theme, PTemplate from cuchulu.libraries.urls import make_media_url import os #from werkzeug.utils import secure_filename import pathlib try: import ujson as json except: import json env=env_theme(__file__) t=PTemplate(env) pages_modules_to_search=[] if hasattr(config, 'pages_modules_to_search'): pages_modules_to_search=config.pages_modules_to_search for mod in pages_modules_to_search: t.env.directories.insert(0, mod.replace('.', '/')+'/templates') @pages2_app.route('/page/') @pages2_app.route('/page/', name="pages2_app.pages2_home") def pages2_home(page_id=0, slug=''): conn=WebModel.connection() page=Page2(conn) page.show_formatted=True if page_id: page.set_conditions('WHERE id=%s', [page_id]) if slug: page.set_conditions('WHERE slugify=%s', [slug]) arr_page=page.select_a_row_where() conn.close() if arr_page: arr_final_text=[] arr_text=json.loads(arr_page['text']) return t.load_template('page2.phtml', title_page=arr_page['title'], content_page=arr_text) else: abort(404, 'Page not found') @pages2_app.route('/home/') def pages_home(): return "" if config.default_module=="pages2": home=pages2_app.route("/")(pages2_home)