Source

pinyomi / www / settings.py

Full commit
# -*- coding: utf-8 -*-
#----------------------------------------------------------------------------#
# settings.py
# Lars Yencken <lars.yencken@gmail.com>
# vim: ts=4 sw=4 sts=4 et tw=78:
# Fri Dec  8 16:09:28 2006
#
#----------------------------------------------------------------------------#

""" Settings and configuration for the web interface of the pinyin lookup
    system.
"""

#----------------------------------------------------------------------------#

from os import path, environ, mkdir

#----------------------------------------------------------------------------#
# BACKEND SETTINGS
#----------------------------------------------------------------------------#

# How long the words are.
MAX_WORD_LENGTH = 5

#----------------------------------------------------------------------------#
# TRANSLITERATION MODELS
#----------------------------------------------------------------------------#

# The character representing an unknown foreign char.
UNKNOWN_WILDCARD = '?'

# Whether or not to use the extra similarity candidates provided by Jin for
# the hanzi-to-kanji mapping.
USE_SIMILARITY_MAPPING = False

# Which "quality" of cognate set to use. Can be 'p', 'q', 'r' or 'u', in
# increasing size. The smaller the size, the better the quality.
PROOFED_COGNATE_SET = 'q'

#----------------------------------------------------------------------------#
# READING MODELS
#----------------------------------------------------------------------------#

# The probability of making a reading error on a single kana segment.
P_KANA_READING_ERROR = 0.05

# The probability of making a reading error on a single pinyin reading.
P_PINYIN_READING_ERROR = 0.05

#----------------------------------------------------------------------------#
# EVALUATION SETTINGS
#----------------------------------------------------------------------------#

# How many stimulus we show in an entire experiment. Ideally the experiment
# should not be too long, otherwise people will not finish it.
NUM_STIMULUS_PER_USER = 30 

# How many words we show to the user on each screen.
NUM_STIMULUS_PER_PAGE = 3 
NUM_READINGS_PER_STIMULUS = 3

# Session will be expired when browser is closed
SESSION_EXPIRE_AT_BROWSER_CLOSE = True

#----------------------------------------------------------------------------#
# PIXEL SETTINGS
#----------------------------------------------------------------------------#

# The height and width of images rendered by the pixel module.
PIXEL_DEFAULT_SIZE = 60

PIXEL_DEFAULT_FONT = 'cyberbit'

#----------------------------------------------------------------------------#
# RESULTS SCORING
#----------------------------------------------------------------------------#

# How many decimal places to show for a score.
SCORE_DECIMAL_PLACES = 3

# A constant bonus added to every score. This is done to make scores positive,
# since people find it easier to compare positive numbers than negative
# numbers.
SCORE_BONUS = 30

#----------------------------------------------------------------------------#
# SERVER SETTINGS
#----------------------------------------------------------------------------#

# Whether to print the query to the server log.
DISPLAY_DATABASE_QUERY = False

MAX_RESULTS_PER_QUERY = 500

SETTINGS_FILE = __file__

DEBUG = True
TEMPLATE_DEBUG = DEBUG

DEFAULT_ENCODING = 'utf8'
DATABASE_ENCODING = 'utf8'

ROOT_DIR = path.join(path.dirname(__file__), '..')
DATA_DIR = path.join(environ['HOME'], 'Data')
TEMP_DIR = path.join(ROOT_DIR, 'tmp')
CACHE_DIR = path.join(TEMP_DIR, 'cache')
LOG_DIR = path.join(TEMP_DIR, 'log')

ADMINS = (
    # ('Your Name', 'your_email@domain.com'),
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'mysql_old'           # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = 'pinyomi'             # Or path to database file if using sqlite3.
DATABASE_USER = 'pinyomiuser'             # Not used with sqlite3.
DATABASE_PASSWORD = 'pinyomipass'         # Not used with sqlite3.
DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.

# Local time zone for this installation. All choices can be found here:
# http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
TIME_ZONE = 'Japan'

# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

ROOT_DIR = path.abspath(path.join(path.dirname(__file__), '..'))

MEDIA_DIR = path.join(ROOT_DIR, 'www', 'media')

# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
MEDIA_URL = '/media/'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = '9@%i&z))ec5vy^p!c0p=3pnmq(z(o8#s4z@#e%wuf0#a%+51!i'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.load_template_source',
    'django.template.loaders.app_directories.load_template_source',
#     'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.middleware.doc.XViewMiddleware',
)

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.core.context_processors.auth',
    'django.core.context_processors.debug',
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'www.context_processors.pinyomi_context',
)

ROOT_URLCONF = 'www.urls'

TEMPLATE_DIRS = (
    path.join(ROOT_DIR, 'www', 'templates'),
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.admin',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'pinyin',
    'eval',
)

SERVER_PREFIX = ''

#----------------------------------------------------------------------------#

# Override any of these settings with another file of locally provided
# settings. We do this so that we can use settings outside of version control.
try:
    from localSettings import *
except ImportError:
    pass

#----------------------------------------------------------------------------#

for dirName in TEMP_DIR, CACHE_DIR, LOG_DIR:
    if not path.isdir(dirName):
        mkdir(dirName)

#----------------------------------------------------------------------------#