1
|
import os
|
2
|
import cPickle
|
3
|
|
4
|
from quixote import get_request
|
5
|
|
6
|
from Defaults import *
|
7
|
|
8
|
from qommon.publisher import set_publisher_class, QommonPublisher
|
9
|
|
10
|
from root import RootDirectory
|
11
|
from admin import RootDirectory as AdminRootDirectory
|
12
|
|
13
|
from sessions import StorageSessionManager
|
14
|
from users import User
|
15
|
|
16
|
class LarpePublisher(QommonPublisher):
|
17
|
APP_NAME = 'larpe'
|
18
|
APP_DIR = APP_DIR
|
19
|
DATA_DIR = DATA_DIR
|
20
|
ERROR_LOG = ERROR_LOG
|
21
|
WEB_ROOT = WEB_ROOT
|
22
|
|
23
|
supported_languages = ['fr']
|
24
|
|
25
|
root_directory_class = RootDirectory
|
26
|
admin_directory_class = AdminRootDirectory
|
27
|
|
28
|
session_manager_class = StorageSessionManager
|
29
|
user_class = User
|
30
|
|
31
|
def get_application_static_files_root_url(self):
|
32
|
return '%s/%s/' % (get_request().environ['SCRIPT_NAME'], WEB_ROOT)
|
33
|
|
34
|
def set_app_dir(self, request):
|
35
|
self.app_dir = os.path.join(self.APP_DIR, request.get_server().lower().split(':')[0])
|
36
|
self.reload_cfg()
|
37
|
if self.cfg.has_key('proxy_hostname'):
|
38
|
self.app_dir = os.path.join(self.APP_DIR, self.cfg['proxy_hostname'])
|
39
|
if self.app_dir is not None and not os.path.exists(self.app_dir):
|
40
|
os.mkdir(self.app_dir)
|
41
|
return True
|
42
|
|
43
|
cfg = None
|
44
|
def write_cfg(self, directory=None):
|
45
|
dump = cPickle.dumps(self.cfg)
|
46
|
if directory is None:
|
47
|
directory = self.app_dir
|
48
|
filename = os.path.join(directory, 'config.pck')
|
49
|
open(filename, 'w').write(dump)
|
50
|
|
51
|
set_publisher_class(LarpePublisher)
|
52
|
extra_dir = os.path.join(os.path.dirname(__file__), 'plugins','site_authentication')
|
53
|
LarpePublisher.register_extra_dir(extra_dir)
|