Little fixed in bug of mimetypes in index.py

This commit is contained in:
Antonio de la Rosa 2016-04-03 04:02:48 +02:00
parent e23bd6cf37
commit 79485fc599
3 changed files with 57 additions and 7 deletions

View file

@ -5,6 +5,7 @@ import os
import shutil
import getpass
from pathlib import Path
from base64 import b64encode
from paramecio.cromosoma.webmodel import WebModel
from paramecio.modules.admin.models.admin import UserAdmin
@ -41,7 +42,7 @@ def start():
except:
print('Error: cannot create the directory. Check if exists and if you have permissions')
# Copy the files
# Copy the files. Need optimization, use an array for save the filenames and a simple for loop.
try:
@ -94,7 +95,7 @@ def start():
try:
shutil.copy(workdir+'/settings/modules.py.admin', path_settings+'/modules.py')
shutil.copy(workdir+'/settings/modules.py', path_settings+'/modules.py')
except:
@ -107,6 +108,23 @@ def start():
except:
print('Error: cannot symlink paramecio in new site')
f=open(path_settings+'/config.py', 'r')
conf=f.read()
f.close()
random_bytes = os.urandom(24)
secret_key_session = b64encode(random_bytes).decode('utf-8').strip()
conf=conf.replace('im smoking fool', secret_key_session)
f=open(path_settings+'/config.py', 'w')
f.write(conf)
f.close()
# Question about mysql configuration? If yes, install configuration
s=input('Do you want use paramecio with MySQL database? y/n: ')
@ -159,6 +177,8 @@ def start():
try:
shutil.copy(workdir+'/settings/modules.py.admin', path_settings+'/modules.py')
shutil.copy(workdir+'/settings/config_admin.py.sample', path_settings+'/config_admin.py')
useradmin=UserAdmin()

View file

@ -16,7 +16,8 @@ if config.yes_static==True:
@route('/media/<filename:path>')
def send_static(filename):
mimetype=guess_type(workdir+'/themes/'+config.theme+'/media/'+filename)
return static_file(filename, root=workdir+'/themes/'+config.theme+'/media/', mimetype=mimetype)
return static_file(filename, root=workdir+'/themes/'+config.theme+'/media/', mimetype=mimetype[0])
#def add_func_static_module(module):
@ -122,6 +123,7 @@ app.add_hook('before_request', print_cookie)
if config.session_enabled==True:
#Create dir for sessions
if 'session_data_dir' in config.session_opts:
if not os.path.isdir(config.session_opts['session.data_dir']):
os.makedirs(config.session_opts['session.data_dir'], 0o700, True)

View file

@ -48,12 +48,40 @@ session_enabled=True
cookie_name = 'paramecio.session'
#More simple sessions. Save the session in a file in ./sessions directory.
"""
session_opts = {
'session.type': 'file',
'session.cookie_expires': False,
'session.data_dir': './sessions',
'session.auto': True
'session.auto': False, # Is better use s.save by performance
}
"""
# More fast methods for beaker sessions.
# Method for save info in cipher cookie. Don't use it if you want save many info in the session (cookies have 4k size limit normally). The default.
session_opts = {
'session.type': 'cookie',
'session.cookie_expires': False,
'session.data_dir': './sessions',
'session.auto': False, # Is better use s.save by performance
'session.validate_key': 'im smoking fool' #Key Generated by paramecio cmd using os.random, more secure if you want add or change random characters
}
# Method for save info in a memcached server.
"""
session_opts = {
'session.type': 'ext:memcached',
'session.auto': False, # Is better use session.save by performance
'session.url': '127.0.0.1:11211'
}
"""
cache_session_opts = {