many improvements from Vladyslav

This commit is contained in:
mdipierro
2012-07-14 22:45:32 -05:00
parent 709038cc0a
commit 1b34f47ec9
14 changed files with 63 additions and 47 deletions
+11 -13
View File
@@ -16,7 +16,6 @@ import time
import datetime
from http import HTTP
from gzip import open as gzopen
from settings import global_settings
__all__ = [
@@ -71,16 +70,6 @@ def readlines_file(filename, mode='r'):
"applies .split('\n') to the output of read_file()"
return read_file(filename, mode).split('\n')
def abspath(*relpath, **base):
"convert relative path to absolute path based (by default) on applications_parent"
path = os.path.join(*relpath)
gluon = base.get('gluon', False)
if os.path.isabs(path):
return path
if gluon:
return os.path.join(global_settings.gluon_parent, path)
return os.path.join(global_settings.applications_parent, path)
def mktree(path):
head,tail =os.path.split(path)
@@ -396,6 +385,15 @@ def make_fake_file_like_object():
return LogFile()
from settings import global_settings # we need to import settings here because
# settings imports fileutils too
def abspath(*relpath, **base):
"convert relative path to absolute path based (by default) on applications_parent"
path = os.path.join(*relpath)
gluon = base.get('gluon', False)
if os.path.isabs(path):
return path
if gluon:
return os.path.join(global_settings.gluon_parent, path)
return os.path.join(global_settings.applications_parent, path)
+1 -13
View File
@@ -52,15 +52,7 @@ from custom_import import custom_import_install
# The two are identical unless web2py_path is changed via the web2py.py -f folder option
# main.web2py_path is the same as applications_parent (for backward compatibility)
if not hasattr(os, 'mkdir'):
global_settings.db_sessions = True
if global_settings.db_sessions is not True:
global_settings.db_sessions = set()
global_settings.gluon_parent = os.environ.get('web2py_path', os.getcwd())
global_settings.applications_parent = global_settings.gluon_parent
web2py_path = global_settings.applications_parent # backward compatibility
global_settings.app_folders = set()
global_settings.debugging = False
custom_import_install(web2py_path)
@@ -107,11 +99,7 @@ requests = 0 # gc timer
# pattern used to validate client address
regex_client = re.compile('[\w\-:]+(\.[\w\-]+)*\.?') # ## to account for IPV6
version_info = open(abspath('VERSION', gluon=True), 'r')
web2py_version = parse_version(version_info.read().strip())
version_info.close()
global_settings.web2py_version = web2py_version
web2py_version = global_settings.web2py_version
try:
import rocket
+31 -3
View File
@@ -4,13 +4,41 @@ Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu>
License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
"""
import os
import sys
import platform
from storage import Storage
global_settings = Storage()
settings = global_settings # legacy compatibility
if not hasattr(os, 'mkdir'):
global_settings.db_sessions = True
if global_settings.db_sessions is not True:
global_settings.db_sessions = set()
global_settings.gluon_parent = os.environ.get('web2py_path', os.getcwd())
global_settings.applications_parent = global_settings.gluon_parent
global_settings.app_folders = set()
global_settings.debugging = False
global_settings.is_pypy = hasattr(platform,'python_implementation') and \
platform.python_implementation() == 'PyPy'
global_settings.is_jython = 'java' in sys.platform.lower() or \
hasattr(sys, 'JYTHON_JAR') or \
str(sys.copyright).find('Jython') > 0
version_info = open(os.path.join(global_settings.gluon_parent, 'VERSION'), 'r')
raw_version_string = version_info.read().strip()
version_info.close()
from fileutils import parse_version # we need fileutils import here, because
# fileutils also imports settings
global_settings.web2py_version = parse_version(raw_version_string)
+3 -1
View File
@@ -758,6 +758,8 @@ class SQLFORM(FORM):
labels={'name': 'Your name'},
linkto=URL(f='table/db/')
"""
from gluon import current
T = current.T
self.ignore_rw = ignore_rw
self.formstyle = formstyle
@@ -980,7 +982,7 @@ class SQLFORM(FORM):
if not readonly:
if 'submit' in buttons:
widget = self.custom.submit = INPUT(_type='submit',
_value=submit_button)
_value=T(submit_button))
elif buttons:
widget = self.custom.submit = DIV(*buttons)
if self.custom.submit: